Blender  V3.3
Enumerations | Functions
Freestyle::GeomUtils Namespace Reference

Enumerations

enum  intersection_test { DONT_INTERSECT , DO_INTERSECT , COLINEAR , COINCIDENT }
 

Functions

bool intersect2dSegPoly (Vec2r *seg, Vec2r *poly, unsigned n)
 
bool intersect2dSeg2dArea (const Vec2r &min, const Vec2r &max, const Vec2r &A, const Vec2r &B)
 
bool include2dSeg2dArea (const Vec2r &min, const Vec2r &max, const Vec2r &A, const Vec2r &B)
 
intersection_test intersect2dSeg2dSeg (const Vec2r &p1, const Vec2r &p2, const Vec2r &p3, const Vec2r &p4, Vec2r &res)
 
intersection_test intersect2dLine2dLine (const Vec2r &p1, const Vec2r &p2, const Vec2r &p3, const Vec2r &p4, Vec2r &res)
 
intersection_test intersect2dSeg2dSegParametric (const Vec2r &p1, const Vec2r &p2, const Vec2r &p3, const Vec2r &p4, real &t, real &u, real epsilon)
 
bool overlapPlaneBox (Vec3r &normal, real d, Vec3r &maxbox)
 
bool overlapTriangleBox (Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3])
 
bool intersectRayTriangle (const Vec3r &orig, const Vec3r &dir, const Vec3r &v0, const Vec3r &v1, const Vec3r &v2, real &t, real &u, real &v, const real epsilon)
 
intersection_test intersectRayPlane (const Vec3r &orig, const Vec3r &dir, const Vec3r &norm, const real d, real &t, const real epsilon)
 
bool intersectRayBBox (const Vec3r &orig, const Vec3r &dir, const Vec3r &boxMin, const Vec3r &boxMax, real t0, real t1, real &tmin, real &tmax, real)
 
bool includePointTriangle (const Vec3r &P, const Vec3r &A, const Vec3r &B, const Vec3r &C)
 
void transformVertex (const Vec3r &vert, const Matrix44r &matrix, Vec3r &res)
 
void transformVertices (const vector< Vec3r > &vertices, const Matrix44r &trans, vector< Vec3r > &res)
 
Vec3r rotateVector (const Matrix44r &mat, const Vec3r &v)
 
void fromCoordAToCoordB (const Vec3r &p, Vec3r &q, const real transform[4][4])
 
void fromWorldToCamera (const Vec3r &p, Vec3r &q, const real model_view_matrix[4][4])
 
void fromCameraToRetina (const Vec3r &p, Vec3r &q, const real projection_matrix[4][4])
 
void fromRetinaToImage (const Vec3r &p, Vec3r &q, const int viewport[4])
 
void fromWorldToImage (const Vec3r &p, Vec3r &q, const real model_view_matrix[4][4], const real projection_matrix[4][4], const int viewport[4])
 
void fromWorldToImage (const Vec3r &p, Vec3r &q, const real transform[4][4], const int viewport[4])
 
void fromImageToRetina (const Vec3r &p, Vec3r &q, const int viewport[4])
 
void fromRetinaToCamera (const Vec3r &p, Vec3r &q, real focal, const real projection_matrix[4][4])
 
void fromCameraToWorld (const Vec3r &p, Vec3r &q, const real model_view_matrix[4][4])
 
template<class T >
real distPointSegment (const T &P, const T &A, const T &B)
 

Enumeration Type Documentation

◆ intersection_test

Enumerator
DONT_INTERSECT 
DO_INTERSECT 
COLINEAR 
COINCIDENT 

Definition at line 59 of file GeomUtils.h.

Function Documentation

◆ distPointSegment()

template<class T >
real Freestyle::GeomUtils::distPointSegment ( const T P,
const T A,
const T B 
)

Computes the distance from a point P to a segment AB

Definition at line 30 of file GeomUtils.h.

References A, B, usdtokens::b(), P(), and T.

Referenced by Freestyle::GridHelpers::distancePointToPolygon(), and Freestyle::StrokeShaders::CurvePiece::error().

◆ fromCameraToRetina()

void Freestyle::GeomUtils::fromCameraToRetina ( const Vec3r p,
Vec3r q,
const real  projection_matrix[4][4] 
)

Projects from World Coordinates to retina coordinates Returns the point's coordinates expressed in Retina system. p point's coordinates expressed in camera system q vector in which the result will be stored projection_matrix The projection matrix expressed in line major order (OpenGL matrices are column major ordered)

Definition at line 652 of file GeomUtils.cpp.

References fromCoordAToCoordB().

Referenced by Freestyle::SilhouetteGeomEngine::CameraToImage(), fromWorldToImage(), and Freestyle::SilhouetteGeomEngine::ImageToWorldParameter().

◆ fromCameraToWorld()

void Freestyle::GeomUtils::fromCameraToWorld ( const Vec3r p,
Vec3r q,
const real  model_view_matrix[4][4] 
)

Projects from camera coordinates to world coordinates Returns the point's coordinates expressed in the world's coordinates system. p point's coordinates expressed in the camera coordinates system q vector in which the result will be stored model_view_matrix The model view matrix expressed in line major order (OpenGL matrices are column major ordered)

Definition at line 714 of file GeomUtils.cpp.

◆ fromCoordAToCoordB()

void Freestyle::GeomUtils::fromCoordAToCoordB ( const Vec3r p,
Vec3r q,
const real  transform[4][4] 
)
inline

Definition at line 812 of file GeomUtils.cpp.

References transform().

Referenced by fromCameraToRetina(), fromWorldToCamera(), and fromWorldToImage().

◆ fromImageToRetina()

void Freestyle::GeomUtils::fromImageToRetina ( const Vec3r p,
Vec3r q,
const int  viewport[4] 
)

From image to retina p point's coordinates expressed in image system q vector in which the result will be stored viewport The viewport: x,y coordinates followed by width and height (OpenGL like viewport).

Definition at line 693 of file GeomUtils.cpp.

Referenced by Freestyle::SilhouetteGeomEngine::ImageToWorldParameter().

◆ fromRetinaToCamera()

void Freestyle::GeomUtils::fromRetinaToCamera ( const Vec3r p,
Vec3r q,
real  focal,
const real  projection_matrix[4][4] 
)

computes the coordinates of q in the camera coordinates system, using the known z coordinates of the 3D point. That means that this method does not inverse any matrices, it only computes X and Y from x,y and Z) p point's coordinates expressed in retina system q vector in which the result will be stored projection_matrix The projection matrix expressed in line major order (OpenGL matrices are column major ordered)

Definition at line 700 of file GeomUtils.cpp.

◆ fromRetinaToImage()

void Freestyle::GeomUtils::fromRetinaToImage ( const Vec3r p,
Vec3r q,
const int  viewport[4] 
)

From retina to image. Returns the coordinates expressed in Image coordinates system. p point's coordinates expressed in retina system q vector in which the result will be stored viewport The viewport: x,y coordinates followed by width and height (OpenGL like viewport).

Definition at line 657 of file GeomUtils.cpp.

Referenced by Freestyle::SilhouetteGeomEngine::CameraToImage(), fromWorldToImage(), and Freestyle::SilhouetteGeomEngine::ImageToWorldParameter().

◆ fromWorldToCamera()

void Freestyle::GeomUtils::fromWorldToCamera ( const Vec3r p,
Vec3r q,
const real  model_view_matrix[4][4] 
)

Projects from world coordinates to camera coordinates Returns the point's coordinates expressed in the camera's coordinates system. p point's coordinates expressed in world coordinates system q vector in which the result will be stored model_view_matrix The model view matrix expressed in line major order (OpenGL matrices are column major ordered)

Definition at line 647 of file GeomUtils.cpp.

References fromCoordAToCoordB().

Referenced by fromWorldToImage(), and Freestyle::SilhouetteGeomEngine::ImageToWorldParameter().

◆ fromWorldToImage() [1/2]

void Freestyle::GeomUtils::fromWorldToImage ( const Vec3r p,
Vec3r q,
const real  model_view_matrix[4][4],
const real  projection_matrix[4][4],
const int  viewport[4] 
)

From world to image p point's coordinates expressed in world coordinates system q vector in which the result will be stored model_view_matrix The model view matrix expressed in line major order (OpenGL matrices are column major ordered) projection_matrix The projection matrix expressed in line major order (OpenGL matrices are column major ordered) viewport The viewport: x,y coordinates followed by width and height (OpenGL like viewport)

Definition at line 669 of file GeomUtils.cpp.

References fromCameraToRetina(), fromRetinaToImage(), and fromWorldToCamera().

Referenced by Freestyle::SilhouetteGeomEngine::ProjectSilhouette(), and Freestyle::SilhouetteGeomEngine::WorldToImage().

◆ fromWorldToImage() [2/2]

void Freestyle::GeomUtils::fromWorldToImage ( const Vec3r p,
Vec3r q,
const real  transform[4][4],
const int  viewport[4] 
)

From world to image p point's coordinates expressed in world coordinates system q vector in which the result will be stored transform The transformation matrix (gathering model view and projection), expressed in line major order (OpenGL matrices are column major ordered) viewport The viewport: x,y coordinates followed by width and height (OpenGL like viewport)

Definition at line 682 of file GeomUtils.cpp.

References fromCoordAToCoordB(), and transform().

◆ include2dSeg2dArea()

bool Freestyle::GeomUtils::include2dSeg2dArea ( const Vec2r min,
const Vec2r max,
const Vec2r A,
const Vec2r B 
)

check whether a 2D segment is included in a 2D region or not

Definition at line 36 of file GeomUtils.cpp.

References A, B, max, and min.

Referenced by Freestyle::ViewEdge::include_in_2d_area().

◆ includePointTriangle()

bool Freestyle::GeomUtils::includePointTriangle ( const Vec3r P,
const Vec3r A,
const Vec3r B,
const Vec3r C 
)

Checks whether 3D point P lies inside or outside of the triangle ABC

Definition at line 573 of file GeomUtils.cpp.

References A, B, C, K, L, N, and P().

◆ intersect2dLine2dLine()

intersection_test Freestyle::GeomUtils::intersect2dLine2dLine ( const Vec2r p1,
const Vec2r p2,
const Vec2r p3,
const Vec2r p4,
Vec2r res 
)

Definition at line 97 of file GeomUtils.cpp.

References COLINEAR, DO_INTERSECT, fabs(), and Freestyle::M_EPSILON.

Referenced by Freestyle::Strip::createStrip().

◆ intersect2dSeg2dArea()

bool Freestyle::GeomUtils::intersect2dSeg2dArea ( const Vec2r min,
const Vec2r max,
const Vec2r A,
const Vec2r B 
)

check whether a 2D segment intersect a 2D region or not

Definition at line 15 of file GeomUtils.cpp.

References A, B, intersect2dSegPoly(), max, and min.

Referenced by Freestyle::crossesProscenium(), Freestyle::ViewEdge::intersect_2d_area(), and Freestyle::Predicates1D::WithinImageBoundaryUP1D::operator()().

◆ intersect2dSeg2dSeg()

intersection_test Freestyle::GeomUtils::intersect2dSeg2dSeg ( const Vec2r p1,
const Vec2r p2,
const Vec2r p3,
const Vec2r p4,
Vec2r res 
)

Definition at line 45 of file GeomUtils.cpp.

References COLINEAR, DO_INTERSECT, DONT_INTERSECT, fabs(), and Freestyle::M_EPSILON.

◆ intersect2dSeg2dSegParametric()

intersection_test Freestyle::GeomUtils::intersect2dSeg2dSegParametric ( const Vec2r p1,
const Vec2r p2,
const Vec2r p3,
const Vec2r p4,
real t,
real u,
real  epsilon 
)

◆ intersect2dSegPoly()

bool Freestyle::GeomUtils::intersect2dSegPoly ( Vec2r seg,
Vec2r poly,
unsigned  n 
)
inline

Definition at line 742 of file GeomUtils.cpp.

References D, e, fabs(), Freestyle::M_EPSILON, N, PERP, and t.

Referenced by intersect2dSeg2dArea().

◆ intersectRayBBox()

bool Freestyle::GeomUtils::intersectRayBBox ( const Vec3r orig,
const Vec3r dir,
const Vec3r boxMin,
const Vec3r boxMax,
real  t0,
real  t1,
real tmin,
real tmax,
real  epsilon = M_EPSILON 
)

Intersection Ray-Bounding box (axis aligned). Adapted from Williams et al, "An Efficient Robust Ray-Box Intersection Algorithm", JGT 10:1 (2005), pp. 49-54.

Definition at line 524 of file GeomUtils.cpp.

References bounds(), KDL::sign(), Freestyle::VecMat::Vec3< T >::x(), Freestyle::VecMat::Vec3< T >::y(), and Freestyle::VecMat::Vec3< T >::z().

Referenced by Freestyle::Grid::initInfiniteRay().

◆ intersectRayPlane()

intersection_test Freestyle::GeomUtils::intersectRayPlane ( const Vec3r orig,
const Vec3r dir,
const Vec3r norm,
const real  d,
real t,
const real  epsilon = M_EPSILON 
)

◆ intersectRayTriangle()

bool Freestyle::GeomUtils::intersectRayTriangle ( const Vec3r orig,
const Vec3r dir,
const Vec3r v0,
const Vec3r v1,
const Vec3r v2,
real t,
real u,
real v,
const real  epsilon = M_EPSILON 
)

Fast, Minimum Storage Ray-Triangle Intersection, adapted from Tomas Möller and Ben Trumbore code.

Definition at line 430 of file GeomUtils.cpp.

References blender::robust_pred::epsilon, t, v, v1, and v2.

Referenced by Freestyle::Geometry::Polygon3r::rayIntersect().

◆ overlapPlaneBox()

bool Freestyle::GeomUtils::overlapPlaneBox ( Vec3r normal,
real  d,
Vec3r maxbox 
)
inline

Definition at line 789 of file GeomUtils.cpp.

References normal, X, and Z.

Referenced by overlapTriangleBox().

◆ overlapTriangleBox()

bool Freestyle::GeomUtils::overlapTriangleBox ( Vec3r boxcenter,
Vec3r boxhalfsize,
Vec3r  triverts[3] 
)

Box-triangle overlap test, adapted from Tomas Akenine-Möller code

Definition at line 345 of file GeomUtils.cpp.

References AXISTEST_X01, AXISTEST_X2, AXISTEST_Y02, AXISTEST_Y1, AXISTEST_Z0, AXISTEST_Z12, fabs(), FINDMINMAX, max, min, normal, overlapPlaneBox(), v1, v2, X, Y, and Z.

Referenced by Freestyle::Grid::insertOccluder(), and Freestyle::GridHelpers::insideProscenium().

◆ rotateVector()

Vec3r Freestyle::GeomUtils::rotateVector ( const Matrix44r mat,
const Vec3r v 
)

Definition at line 631 of file GeomUtils.cpp.

References Freestyle::VecMat::Vec< T, N >::normalize(), and v.

◆ transformVertex()

void Freestyle::GeomUtils::transformVertex ( const Vec3r vert,
const Matrix44r matrix,
Vec3r res 
)

◆ transformVertices()

void Freestyle::GeomUtils::transformVertices ( const vector< Vec3r > &  vertices,
const Matrix44r trans,
vector< Vec3r > &  res 
)

Definition at line 622 of file GeomUtils.cpp.

References transformVertex().

Referenced by Freestyle::WingedEdgeBuilder::buildWShape().