Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • e31fa09
  • /
  • src
  • /
  • external
  • /
  • ArcSim
  • /
  • geometry.hpp
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:ba9bbe17d8684b5f45d098ef6b2693ea3e64613a
directory badge
swh:1:dir:70754d5bbbcb118b85e3fd43533ce31be60ab86b

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
geometry.hpp
/*
Copyright ©2013 The Regents of the University of California
(Regents). All Rights Reserved. Permission to use, copy, modify, and
distribute this software and its documentation for educational,
research, and not-for-profit purposes, without fee and without a
signed licensing agreement, is hereby granted, provided that the
above copyright notice, this paragraph and the following two
paragraphs appear in all copies, modifications, and
distributions. Contact The Office of Technology Licensing, UC
Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
(510) 643-7201, for commercial licensing opportunities.

IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/

#ifndef GEOMETRY_HPP
#define GEOMETRY_HPP

#include "mesh.hpp"
#include "util.hpp"

double signed_vf_distance(const Vec3 &x,
	const Vec3 &y0, const Vec3 &y1, const Vec3 &y2,
	Vec3 *n, double *w);

double signed_ee_distance(const Vec3 &x0, const Vec3 &x1,
	const Vec3 &y0, const Vec3 &y1,
	Vec3 *n, double *w);

double unsigned_vf_distance(const Vec3 &x,
	const Vec3 &y0, const Vec3 &y1, const Vec3 &y2,
	Vec3 *n, double *w);

double unsigned_ee_distance(const Vec3 &x0, const Vec3 &x1,
	const Vec3 &y0, const Vec3 &y1,
	Vec3 *n, double *w);

double signed_ve_distance(const Vec3 &x, const Vec3 &y0, const Vec3 &y1,
	Vec3* n, double *w);

// NICK
double unsigned_vv_distance(const Vec3 &x, const Vec3 &y);
double incedent_angle(const Vert* v, const Face* f);

Vec3 get_barycentric_coords(const Vec2 &point, const Face *face);

Face* get_enclosing_face(const Mesh& mesh, const Vec2& u,
	Face *starting_face_hint = NULL);

enum Space { MS, PS, WS }; // material space, plastic space, world space

template <Space s> const Vec3 &pos(const Node *node);
template <Space s> inline Vec3 &pos(Node *node);
template <Space s> const Vec3 &pos(const Vert *vert);
template <Space s> inline Vec3 &pos(Vert *vert);
template <Space s> Vec3 normal(const Face *face);
template <Space s> Vec3 normal(const Node* node);
template <Space s> double dihedral_angle(const Edge *edge);
double dihedral_angle(const Vec3& p0, const Vec3& p1, const Vec3& n0, const Vec3& n1);
template <Space s> Mat3x3 curvature(const Face *face);
template <Space s> Mat2x2 projected_curvature(const Face *face, const Mat2x3& base);

inline double area(const Vec3& u0, const Vec3& u1, const Vec3& u2) { return 0.5*norm(cross(u1 - u0, u2 - u0)); }
inline double area(const Face* face) { return area(face->v[0]->u, face->v[1]->u, face->v[2]->u); }
double aspect(const Vec3& u0, const Vec3& u1, const Vec3& u2);
inline double aspect(const Face* face) { return aspect(face->v[0]->u, face->v[1]->u, face->v[2]->u); }
double get_angle(const Vec3& u, const Vec3& v);

// Nick
inline double edge_length(const Edge* edge) { return sqrt(pow(edge->n[0]->verts[0]->u[0] - edge->n[1]->verts[0]->u[0], 2) + pow(edge->n[0]->verts[0]->u[1] - edge->n[1]->verts[0]->u[1], 2)); }
inline double edge_length3D(const Edge* edge) { return sqrt(pow(edge->n[0]->x[0] - edge->n[1]->x[0], 2) + pow(edge->n[0]->x[1] - edge->n[1]->x[1], 2) + pow(edge->n[0]->x[2] - edge->n[1]->x[2], 2)); }

template <Space s> Plane plane_fit(const Mesh& mesh);

Mat3x3 local_base(const Vec3& normal);

bool triangle_ray_test(const Vec3 &x0, const Vec3& x1, const Vec3& x2,
	const Vec3 &s, const Vec3& d, double& z, Vec3* bary = 0);

// -----------------------------------------------------------------------------
// IMPLEMENTATION
//

template <> inline const Vec3 &pos<PS>(const Node *node) { return node->y; }
template <> inline const Vec3 &pos<WS>(const Node *node) { return node->x; }
template <> inline Vec3 &pos<PS>(Node *node) { return node->y; }
template <> inline Vec3 &pos<WS>(Node *node) { return node->x; }
template <> inline const Vec3 &pos<MS>(const Vert *vert) { return vert->u; }
template <> inline const Vec3 &pos<PS>(const Vert *vert) { return vert->node->y; }
template <> inline const Vec3 &pos<WS>(const Vert *vert) { return vert->node->x; }
template <> inline Vec3 &pos<MS>(Vert *vert) { return vert->u; }
template <> inline Vec3 &pos<PS>(Vert *vert) { return vert->node->y; }
template <> inline Vec3 &pos<WS>(Vert *vert) { return vert->node->x; }


#endif

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API