Library of Assembled Shared Sources
|
set of geometrical primitives
lass::prim is the library for geometrical primitives and related constructions. It consists of structures and classes to represent primitives as vectors, points, lines, planes, polygons etc., some policy classes that can modify the implementation of some of these primitives, and a few related enumerations.
All primitives are templated with an underlying value type (think of floats, doubles, fixed point, ...). This value type can be set as by the template parameter T, and is typedef'ed in all primitives as TValue
(convenient, isn't it? :). It's the subatomic unit (proton if you like) on which more complex types are built.
I think the best way to explore this library, is to give an overview of its components. Here we go ...
If TValue
is the proton, then vectors are the smallest atomic units in lass::prim you can build. Vectors represent a direction, a translation, and we have three of them in our library (with 2, 3 and 4 protons respective :):
The above vectors are free vectors and have no position. To express the position of a location in space, we need points. we have two of these thingies. It's a little unusual to distinguish between vectors and points. Usually, only one is used for both concepts, whether they uses point or vector. Yet, these are totally different mathematical entities. You can add two vectors together, but you can't add two points (what would it mean?). Transforming a vector is different that a point (a vector will only be rotated, a point will also be translated). Points and vectors are clearly to be traited differently. This cries for different classes or structures. In C however, it has little use to do that, because of the lack of function overloading and strong type checking. However, here we are in C++ and the good news is: C++ does have overloading and strong type checking, so we can clearly distinguish between points and vectors in our code. And that's what we do here. For more info on this subject, I gladly refer to [1, 2, 3]. You can see the points as ions: vectors with some extra (or lacking) electrons: same number of protons (same dimension), but not completely the same thing.
One problem of not being able to add and scale points is not being able to use barycentric combinations. This is a linear combination of points in which the sum of all weight is equal to 1. The result of such a combination is a point and is mathematical sensefull. In [1], I didn't find a satisfying solution to this problem, because I wanted to limit myself to eucledian entities. To do barycentric combinations, I had to convert the points to vectors, do the combination, and the convert back to a point. Not only this is a bit clumsy, it didn't guarantee that the sum of the weights would be 1. In [2], I introduced homogenous points to solve this question. And they are also introduced in here. Homogenous points are with the sole capability to do barycentric combinations on points. You can see the homogenous points as points with some extra neutrons: pretty compatible.
So far for the essential building blocks of the more complex primitives. Until now we had the atoms, now we'll build moleculs. The simplest thing we can construct from it are axis-aligned-bounding-boxes.
Objects of infinite size are lines and planes. We have them in parametric and cartesian versions.
For the circular guys:
Objects of not so infinite size: line segments and rays.
Polygons and stuff:
These three classes are iterators over the different axes (components). You can use this instead of directly calling the .x or
.y members of a vector. With these iterators, you can access those components through the
operator
[] .
Namespaces | |
namespace | impl |
implementation details of lass::prim | |
Data Structures | |
class | Aabb2D |
your momma's axis aligned bounding box. More... | |
class | Aabb3D |
your momma's axis aligned bounding box. More... | |
struct | AllowDegenerate |
AllowDegenerate puts the responsibility on the user. More... | |
struct | AutoMinMax |
MinMaxPolicy automatically correcting wrong minima and maxima. More... | |
struct | Bounded |
Parameters supplied to functions must be in the range of the primitive. More... | |
class | Cartesian |
policy for an implementation based on the cartesian equation. More... | |
struct | ColorRGBA |
an [0, 1] floating point RGB colour with Alpha channel. More... | |
class | Combined |
policy for an implementation based on both the cartesian and parametric equation. More... | |
struct | Disk3D |
3D Disk More... | |
struct | IsAlreadyNormalized |
class | Line2D |
2D Line More... | |
class | Line3D |
3D Line More... | |
class | LineSegment2D |
2D Line Segment More... | |
class | LineSegment3D |
3D Line Segment More... | |
class | MinMaxError |
Exception thrown by StrictMinMax. More... | |
struct | NoDegenerate |
This is the default policy. More... | |
struct | Normalized |
Policy to auto-normalize normals. More... | |
class | Parallelogram3D |
A very simple 3D polygon :) More... | |
class | Parametric |
policy for an implementation based on the parametric equation. More... | |
struct | Plane3D |
A 3D hyper plane. More... | |
struct | Point2DH |
homogenous 2D Point More... | |
struct | Point3D |
3D Point More... | |
struct | Point3DH |
homogenous 3D Point More... | |
class | Ray2D |
2D Ray More... | |
class | Ray3D |
3D Ray More... | |
class | SimplePolygon2D |
convex or concave polygon in 2D (not selfintersecting, no holes) More... | |
class | SimplePolygon3D |
convex or concave polygon in 3D (not selfintersecting, no holes) More... | |
struct | Sphere3D |
3D Sphere More... | |
struct | StrictMinMax |
MinMaxPolicy enforcing strict rules for the minima and maxima. More... | |
struct | StrictNoDegenerate |
This is the default policy. More... | |
class | Transformation2D |
a linear 2D transformation More... | |
class | Transformation3D |
a linear 3D transformation More... | |
class | Triangle2D |
A very simple 2D polygon :) More... | |
class | Triangle3D |
A very simple 3D polygon :) More... | |
class | TriangleMesh3D |
One of the simplier meshes. More... | |
struct | Unbounded |
Parameters supplied to functions can go out of the range of the primitive. More... | |
struct | UncheckedMinMax |
MinMaxPolicy that makes it your responsibility to behave well. More... | |
struct | Unnormalized |
Policy to keep normals unnormalized. More... | |
struct | Vector2D |
2D Vector More... | |
struct | Vector3D |
3D Vector More... | |
struct | Vector4D |
4D Vector More... | |
class | XY |
cyclic iterator over xy indices More... | |
class | XYZ |
cyclic iterator over xyz indices More... | |
class | XYZW |
cyclic iterator over xyzw indices More... | |
Enumerations | |
enum | Orientation { oInvalid = 0 , oClockWise = 1 , oCounterClockWise = 2 } |
enumeration of clockwise versus counterclockwise More... | |
enum | Result { rInvalid = 0 , rNone = 1 , rOne = 2 , rTwo = 3 , rInfinite = 4 } |
meta information on the result you have from an operation like an intersection ... More... | |
enum | Side { sInvalid = 0x00 , sFront = 0x01 , sLeft = 0x01 , sBack = 0x02 , sRight = 0x02 , sInside = 0x04 , sOutside = 0x08 , sSurface = 0x10 } |
Different sides of a surface. More... | |
Functions | |
template<typename T, class DegeneratePolicy> | |
bool | triangulate (const SimplePolygon2D< T, DegenerationPolicy > &iPolygon, std::vector< Triangle2D< T > > &oTriangles) |
ColorRGBA | over (const ColorRGBA &a, const ColorRGBA &b) |
placement of foreground a in front of background b. | |
ColorRGBA | in (const ColorRGBA &a, const ColorRGBA &b) |
part of a inside b. | |
ColorRGBA | out (const ColorRGBA &a, const ColorRGBA &b) |
a held out by b, part of a outside b. | |
ColorRGBA | atop (const ColorRGBA &a, const ColorRGBA &b) |
union of a in b and b out a. | |
ColorRGBA | plus (const ColorRGBA &a, const ColorRGBA &b) |
ColorRGBA | through (const ColorRGBA &a, const ColorRGBA &b) |
a seen through color filter b. | |
ColorRGBA::TValue | distance (const ColorRGBA &a, const ColorRGBA &b) |
distance between non-non-premultiplied colours as 3D points (alpha channel is disregarded). | |
template<typename T, class DP> | |
bool | set_difference (const SimplePolygon2D< T, DP > &iPolygonA, const SimplePolygon2D< T, DP > &iPolygonB, std::vector< SimplePolygon2D< T, DP > > &oPolygonsC) |
C = A \ B. | |
template<typename T, class DP> | |
bool | set_union (const SimplePolygon2D< T, DP > &iPolygonA, const SimplePolygon2D< T, DP > &iPolygonB, std::vector< SimplePolygon2D< T, DP > > &oPolygonsC) |
C = A U B. | |
template<typename T, class DP> | |
bool | set_intersect (const SimplePolygon2D< T, DP > &iPolygonA, const SimplePolygon2D< T, DP > &iPolygonB, std::vector< SimplePolygon2D< T, DP > > &oPolygonsC) |
C = (A U B) \ (A \ B) \ (B \ A) | |
template<typename T, class MMPa, class MMPb> | |
const Aabb2D< T, MMPa > | operator+ (const Aabb2D< T, MMPa > &a, const Aabb2D< T, MMPb > &b) |
join two AABBs | |
template<typename T, class MMP> | |
const Aabb2D< T, MMP > | operator+ (const Aabb2D< T, MMP > &a, const Point2D< T > &b) |
add a point to an AABB | |
template<typename T, class MMP> | |
const Aabb2D< T, MMP > | operator+ (const Point2D< T > &a, const Aabb2D< T, MMP > &b) |
add a point to an AABB | |
template<typename T> | |
const Aabb2D< T > | aabb (const Point2D< T > &point) |
create an aabb with a single point in it | |
template<typename T, class MMP> | |
T | distance (const Aabb2D< T, MMP > &a, const Point2D< T > &b) |
distance between AABB and point | |
template<typename T, class MMPa, class MMPb> | |
T | distance (const Aabb2D< T, MMPa > &a, const Aabb2D< T, MMPb > &b) |
distance between two AABBs | |
template<typename T, class MMPa, class MMPb, class MMPr> | |
Result | intersect (const Aabb2D< T, MMPa > &a, const Aabb2D< T, MMPb > &b, Aabb2D< T, MMPr > &result) |
Calculate the intersection of two axis aligned bounding boxes. | |
template<typename T, typename MMPAabb, typename NPRay, typename PPRay> | |
Result | intersect (const Aabb2D< T, MMPAabb > &aabb, const Ray2D< T, NPRay, PPRay > &ray, T &t, const T &tMin=T()) |
Find the intersection of an AABB and ray by their parameter t on the ray. | |
template<typename T, typename MMPAabb, typename NPRay, typename PPRay> | |
Result | intersect (const Aabb2D< T, MMPAabb > &aabb, const Ray2D< T, NPRay, PPRay > &ray, const Vector2D< T > &invDirection, T &t, const T &tMin=T()) |
Find the intersection of an AABB and ray by their parameter t on the ray. | |
template<typename T, class DegeneratePolicy> | |
Aabb2D< T > | aabb (const SimplePolygon2D< T, DegeneratePolicy > &polygon) |
determine axis aligned bounding box of a 2D simple polygon | |
template<typename T, class MMP> | |
Aabb2D< T, MMP > | transform (const Aabb2D< T, MMP > &subject, const Transformation2D< T > &transformation) |
apply transformation to axis aligned bounding box | |
template<typename T> | |
Aabb2D< T > | aabb (const Triangle2D< T > &triangle) |
determine axis aligned bounding box of a 2D triangle | |
template<typename T, class MMPa, class MMPb> | |
const Aabb3D< T, MMPa > | operator+ (const Aabb3D< T, MMPa > &a, const Aabb3D< T, MMPb > &b) |
join two AABBs | |
template<typename T, class MMP> | |
const Aabb3D< T, MMP > | operator+ (const Aabb3D< T, MMP > &a, const Point3D< T > &b) |
add a point to an AABB | |
template<typename T, class MMP> | |
const Aabb3D< T, MMP > | operator+ (const Point3D< T > &a, const Aabb3D< T, MMP > &b) |
add a point to an AABB | |
template<typename T, class MMP> | |
T | distance (const Aabb3D< T, MMP > &a, const Point3D< T > &b) |
distance between AABB and point | |
template<typename T, class MMPa, class MMPb> | |
T | distance (const Aabb3D< T, MMPa > &a, const Aabb3D< T, MMPb > &b) |
distance between two AABBs | |
template<typename T, class MMPa, class MMPb, class MMPr> | |
Result | intersect (const Aabb3D< T, MMPa > &a, const Aabb3D< T, MMPb > &b, Aabb3D< T, MMPr > &result) |
Calculate the intersection of two axis aligned bounding boxes. | |
template<typename T> | |
Aabb3D< T > | aabb (const Disk3D< T > &disk) |
template<typename T> | |
Aabb3D< T > | aabb (const Parallelogram3D< T > ¶llelogram) |
determine axis aligned bounding box of a 3D parallelogram | |
template<typename T, typename MMPAabb, typename NPRay, typename PPRay> | |
Result | intersect (const Aabb3D< T, MMPAabb > &aabb, const Ray3D< T, NPRay, PPRay > &ray, T &t, const T &tMin=T()) |
Find the intersection of an AABB and ray by their parameter t on the ray. | |
template<typename T, typename MMPAabb, typename NPRay, typename PPRay> | |
Result | intersect (const Aabb3D< T, MMPAabb > &aabb, const Ray3D< T, NPRay, PPRay > &ray, const Vector3D< T > &invDirection, T &t, const T &tMin=T()) |
Find the intersection of an AABB and ray by their parameter t on the ray. | |
template<typename T, class EP, class NP> | |
Aabb3D< T > | aabb (const SimplePolygon3D< T, EP, NP > &polygon) |
determine axis aligned bounding box of a 3D simple polygon | |
template<typename T, class EP, class NP, class MMP> | |
SimplePolygon3D< T, EP, NP > | clip (const Aabb3D< T, MMP > &box, const Plane3D< T, EP, NP > &plane) |
Clip a plane to an AABB and get a polygon. | |
template<typename T, class EP, class NP, class MMP> | |
SimplePolygon3D< T, EP, NP > | clip (const Aabb3D< T, MMP > &box, const SimplePolygon3D< T, EP, NP > &polygon) |
Clip a polygon to an AABB . | |
template<typename T> | |
Aabb3D< T > | aabb (const Sphere3D< T > &sphere) |
template<typename T, typename MMP> | |
Sphere3D< T > | boundingSphere (const Aabb3D< T, MMP > &box) |
template<typename T, typename MMP> | |
bool | intersects (const Aabb3D< T, MMP > &aabb, const Sphere3D< T > &sphere) |
template<typename T, typename MMP> | |
bool | intersects (const Sphere3D< T > &sphere, const Aabb3D< T, MMP > &aabb) |
template<typename T, typename MMP> | |
bool | collides (const Aabb3D< T, MMP > &aabb, const Sphere3D< T > &sphere) |
template<typename T, typename MMP> | |
bool | collides (const Sphere3D< T > &sphere, const Aabb3D< T, MMP > &aabb) |
template<typename T, class MMP> | |
Aabb3D< T, MMP > | transform (const Aabb3D< T, MMP > &subject, const Transformation3D< T > &transformation) |
apply transformation to axis aligned bounding box | |
template<typename T> | |
Aabb3D< T > | aabb (const Triangle3D< T > &triangle) |
determine axis aligned bounding box of a 3D triangle | |
ColorRGBA | operator+ (const ColorRGBA &a, const ColorRGBA &b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator- (const ColorRGBA &a, const ColorRGBA &b) |
raw subtraction of a and b, including alpha channels | |
ColorRGBA | operator* (const ColorRGBA &a, const ColorRGBA &b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator/ (const ColorRGBA &a, const ColorRGBA &b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator+ (ColorRGBA::TParam a, const ColorRGBA &b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator- (ColorRGBA::TParam a, const ColorRGBA &b) |
raw subtraction of a and b, including alpha channels | |
ColorRGBA | operator* (ColorRGBA::TParam a, const ColorRGBA &b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator/ (ColorRGBA::TParam a, const ColorRGBA &b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator+ (const ColorRGBA &a, ColorRGBA::TParam b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator- (const ColorRGBA &a, ColorRGBA::TParam b) |
raw subtraction of a and b, including alpha channels | |
ColorRGBA | operator* (const ColorRGBA &a, ColorRGBA::TParam b) |
raw addition of a and b, including alpha channels | |
ColorRGBA | operator/ (const ColorRGBA &a, ColorRGBA::TParam b) |
raw addition of a and b, including alpha channels | |
template<typename T> | |
ColorRGBA | transform (const ColorRGBA &subject, const Transformation3D< T > &transformation) |
apply transformation to axis aligned bounding box | |
template<typename T> | |
Sphere3D< T > | boundingSphere (const Disk3D< T > &disk) |
template<typename T, class EP, class NP> | |
T | distance (const Point2D< T > &iA, const Line2D< T, EP, NP > &iB) |
absolute distance between point and line. | |
template<typename T, class EPa, class NPa, class EPb, class NPb> | |
T | distance (const Line2D< T, EPa, NPa > &iA, const Line2D< T, EPb, NPb > &iB) |
absolute distance between two lines | |
template<typename T, class EPa, class NPa, class EPb, class NPb> | |
Result | intersect (const Line2D< T, EPa, NPa > &iA, const Line2D< T, EPb, NPb > &iB, T &oTa, T &oTb) |
intersection of two lines | |
template<typename T, class EPa, class NPa, class EPb, class NPb> | |
Result | intersect (const Line2D< T, EPa, NPa > &iA, const Line2D< T, EPb, NPb > &iB, Point2D< T > &oPoint) |
intersection of two lines | |
template<typename T, class EP1, class NP1, class NP2, class PP2> | |
Result | intersect (const Line2D< T, EP1, NP1 > &line, const Ray2D< T, NP2, PP2 > &ray, T &t, const T &tMin=T()) |
Find the intersection of a line and ray by their parameter t on the ray. | |
template<typename T, class PPa, class PPb> | |
Result | intersect (const LineSegment2D< T, PPa > &a, const LineSegment2D< T, PPb > &b, T &tA, T &tB) |
intersection of two line segments | |
template<typename T, class PPa, class PPb> | |
Result | intersect (const LineSegment2D< T, PPa > &a, const LineSegment2D< T, PPb > &b, Point2D< T > &point) |
intersection of two line segments | |
template<typename T, class PP1, class NP2, class PP2> | |
Result | intersect (const LineSegment2D< T, PP1 > &lineSegment, const Ray2D< T, NP2, PP2 > &ray, T &t, const T &tMin=T()) |
Find the intersection of a ray and a line segment by parameter t on the ray. | |
template<typename T, class EPPlane, class NPPlane, class PPRay> | |
Result | intersect (const Plane3D< T, EPPlane, NPPlane > &plane, const LineSegment3D< T, PPRay > &lineSegment, T &t) |
Find the intersection of a plane and line segment by their parameter t on the ray. | |
template<typename T, class EP, class NP, class PP> | |
LineSegment3D< T, PP > | reflect (const Plane3D< T, EP, NP > &plane, const LineSegment3D< T, PP > &lineSegment) |
reflect a linesegment in a plane. | |
template<typename T, class EP, class NP, class PP> | |
LineSegment3D< T, PP > | project (const Plane3D< T, EP, NP > &plane, const LineSegment3D< T, PP > &lineSegment) |
project a linesegment on a plane. | |
template<typename T, class NP, class PP> | |
Result | intersect (const Parallelogram3D< T > ¶llelogram, const Ray3D< T, NP, PP > &ray, T &u, T &v, T &t, const T &tMin=T()) |
Find the intersection of a ray and a parallelogram by their parameter t on the ray and it's coordinates (u,v) on the parallelogram. | |
template<typename T, class NP, class PP> | |
Result | intersect (const Parallelogram3D< T > ¶llelogram, const Ray3D< T, NP, PP > &ray, T &t, const T &tMin=T()) |
Find the intersection of a ray and a parallelogram by their parameter t on the ray. | |
template<typename T, class EPPlane, class NPPlane, class NPRay, class PPRay> | |
Result | intersect (const Plane3D< T, EPPlane, NPPlane > &plane, const Ray3D< T, NPRay, PPRay > &ray, T &t, const T &tMin=T()) |
Find the intersection of a plane and ray by their parameter t on the ray. | |
template<typename T, class NP> | |
Plane3D< T, Cartesian, NP > | transform (const Plane3D< T, Cartesian, NP > &plane, const Transformation3D< T > &transformation) |
apply transformation to cartesian plane | |
template<typename T, class NP> | |
Plane3D< T, Parametric, NP > | transform (const Plane3D< T, Parametric, NP > &plane, const Transformation3D< T > &transformation) |
apply transformation to parametric plane | |
template<typename T, class NP> | |
Plane3D< T, Combined, NP > | transform (const Plane3D< T, Combined, NP > &plane, const Transformation3D< T > &transformation) |
apply transformation to combined plane | |
template<typename T> | |
Point2D< T > | pointwiseMin (const Point2D< T > &a, const Point2D< T > &b) |
return a point with, for each coordinate, the minimum value of a and b | |
template<typename T> | |
Point2D< T > | pointwiseMax (const Point2D< T > &a, const Point2D< T > &b) |
return a point with, for each coordinate, the maximum value of a and b | |
template<typename T> | |
Point2D< T > | lerp (const Point2D< T > &a, const Point2D< T > &b, typename Point2D< T >::TParam t) |
interpolate linearly between two points: a + t * (b - a) | |
template<typename T> | |
T | doubleTriangleArea (const Point2D< T > &a, const Point2D< T > &b, const Point2D< T > &c) |
returns twice signed area of triangle a,b,c | |
template<typename T> | |
bool | ccw (const Point2D< T > &a, const Point2D< T > &b, const Point2D< T > &c) |
returns true when the line b->c is counter clockwise oriented with respect to a->b | |
template<typename T> | |
bool | cw (const Point2D< T > &a, const Point2D< T > &b, const Point2D< T > &c) |
returns true when the line b->c is clockwise oriented with respect to a->b | |
template<typename T> | |
bool | weakCcw (const Point2D< T > &a, const Point2D< T > &b, const Point2D< T > &c) |
returns true when the line b->c is counter clockwise oriented with respect to a->b. | |
template<typename T> | |
bool | weakCw (const Point2D< T > &a, const Point2D< T > &b, const Point2D< T > &c) |
returns true when the line b->c is counter clockwise oriented with respect to a->b. | |
template<typename T> | |
bool | inCircle (const Point2D< T > &a, const Point2D< T > &b, const Point2D< T > &c, const Point2D< T > &d) |
returns true when the point d is strictly (within numerical precision) in the circle going through a, b and c. | |
template<typename T> | |
Point3D< T >::TValue | distance (const Point3D< T > &a, const Point3D< T > &b) |
return the distance between two points | |
template<typename T> | |
Point3D< T > | pointwiseMin (const Point3D< T > &a, const Point3D< T > &b) |
return a point with, for each coordinate, the minimum value of a and b | |
template<typename T> | |
Point3D< T > | lerp (const Point3D< T > &a, const Point3D< T > &b, typename Point3D< T >::TParam t) |
interpolate linearly between two points: a + t * (b - a) | |
template<typename T> | |
Point3D< T > | pointwiseMax (const Point3D< T > &a, const Point3D< T > &b) |
return a point with, for each coordinate, the maximum value of a and b | |
template<typename T, class DP, class NP, class PP> | |
Result | intersect (const SimplePolygon2D< T, DP > &polygon, const Ray2D< T, NP, PP > &ray, T &t, const T &tMin=T()) |
Find the intersection of a ray and a triangle by their parameter t on the ray. | |
template<typename T, class NP, class PP> | |
Result | intersect (const Triangle2D< T > &triangle, const Ray2D< T, NP, PP > &ray, T &t, const T &tMin=T()) |
Find the intersection of a ray and a triangle by their parameter t on the ray. | |
template<typename T, class EP1, class NP1, class NP2, class PP2> | |
Result | intersect (const SimplePolygon3D< T, EP1, NP1 > &polygon, const Ray3D< T, NP2, PP2 > &triangle, T &t, const T &tMin) |
Find the intersection of a ray and a simple polygon by their parameter t on the ray. | |
template<typename T, class NP, class PP> | |
Ray3D< T, NP, PP > | transform (const Ray3D< T, NP, PP > &subject, const Transformation3D< T > &transformation) |
apply transformation to ray | |
template<typename T, class NP, class PP> | |
Ray3D< T, NP, PP > | transform (const Ray3D< T, NP, PP > &subject, const Transformation3D< T > &transformation, T &tRay) |
apply transformation to ray, and rescale a parameter to represent same point | |
template<typename T, class NP, class PP> | |
Result | intersect (const Triangle3D< T > &triangle, const Ray3D< T, NP, PP > &ray, T &t, const T &tMin=T()) |
Find the intersection of a ray and a triangle by their parameter t on the ray. | |
template<typename T, class NP, class PP> | |
Result | intersect (const Triangle3D< T > &triangle, const Ray3D< T, NP, PP > &ray, T &u, T &v, T &t, const T &tMin=T()) |
Find the intersection of a ray and a triangle by their parameter t on the ray and it's coordinates (u,v) on the triangle. | |
template<typename T, typename DP, typename PP> | |
bool | intersects (const SimplePolygon2D< T, DP > &poly, const LineSegment2D< T, PP > &segment) |
O(N) with N is size of poly. | |
template<typename T, typename DP, typename PP> | |
bool | intersects (const LineSegment2D< T, PP > &segment, const SimplePolygon2D< T, DP > &poly) |
O(N) with N is size of poly. | |
template<typename T, typename DP1, typename DP2> | |
bool | intersects (const SimplePolygon2D< T, DP1 > &a, const SimplePolygon2D< T, DP2 > &b) |
O(M+N) with M and N the sizes of the polygons. | |
template<typename T, class EP, class NP, class PP> | |
Result | intersect (const SimplePolygon3D< T, EP, NP > &iPolygon, const LineSegment3D< T, PP > &iSegment, T &oT, const T &iMinT) |
Find the intersection of a line segment and a simple polygon by their parameter t on the line segment. | |
template<typename T, class EP1, class NP1, class EP2, class NP2> | |
SimplePolygon3D< T, EP2, NP2 > | clip (const Plane3D< T, EP1, NP1 > &iPlane, const SimplePolygon3D< T, EP2, NP2 > &iPolygon) |
Clip a polygon to a plane. | |
template<typename T> | |
Transformation2D< T > | concatenate (const Transformation2D< T > &first, const Transformation2D< T > &second) |
concatenate two transformations first and second in one. | |
template<typename T> | |
Vector2D< T > | transform (const Vector2D< T > &subject, const Transformation2D< T > &transformation) |
apply transformation to a vector | |
template<typename T> | |
Point2D< T > | transform (const Point2D< T > &subject, const Transformation2D< T > &transformation) |
apply transformation to a point | |
template<typename T> | |
Vector2D< T > | normalTransform (const Vector2D< T > &subject, const Transformation2D< T > &transformation) |
apply transformation to a normal vector. | |
template<typename T> | |
std::pair< Vector2D< T >, T > | normalTransform (const std::pair< Vector2D< T >, T > &subject, const Transformation2D< T > &transformation) |
apply transformation to a 3D normal vector. | |
template<typename T> | |
Transformation3D< T > | concatenate (const Transformation3D< T > &first, const Transformation3D< T > &second) |
concatenate two transformations first and second in one. | |
template<typename T> | |
Vector3D< T > | transform (const Vector3D< T > &subject, const Transformation3D< T > &transformation) |
apply transformation to a vector | |
template<typename T> | |
Point3D< T > | transform (const Point3D< T > &subject, const Transformation3D< T > &transformation) |
apply transformation to a point | |
template<typename T> | |
Vector3D< T > | normalTransform (const Vector3D< T > &subject, const Transformation3D< T > &transformation) |
apply transformation to a normal vector. | |
template<typename T> | |
std::pair< Vector3D< T >, T > | normalTransform (const std::pair< Vector3D< T >, T > &subject, const Transformation3D< T > &transformation) |
apply transformation to a 4D normal vector. | |
template<typename T> | |
T | partialVoronoiArea (const Triangle2D< T > iT, int vertexIndex) |
Returns the surface of the partial Voronoi cell constructed around vertex vertexIndex (say vertex a in triangle abc). | |
template<typename T> | |
Vector2D< T >::TValue | dot (const Vector2D< T > &a, const Vector2D< T > &b) |
dot product. | |
template<typename T> | |
Vector2D< T >::TValue | cos (const Vector2D< T > &a, const Vector2D< T > &b) |
returns cosine of angle between both vectors. | |
template<typename T> | |
Vector2D< T >::TValue | perpDot (const Vector2D< T > &a, const Vector2D< T > &b) |
perp dot product (cross product for 2D vectors). | |
template<typename T> | |
Vector2D< T > | operator+ (const Vector2D< T > &a, const Vector2D< T > &b) |
componentwise addition | |
template<typename T> | |
Vector2D< T > | operator- (const Vector2D< T > &a, const Vector2D< T > &b) |
componentwise subtraction | |
template<typename T> | |
Vector2D< T > | operator* (const Vector2D< T > &a, const Vector2D< T > &b) |
Componentwise multiplication. | |
template<typename T> | |
Vector2D< T > | operator/ (const Vector2D< T > &a, const Vector2D< T > &b) |
Componentwise division. | |
template<typename T> | |
Vector2D< T > | operator+ (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
add b to all components of a. | |
template<typename T> | |
Vector2D< T > | operator- (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
subtract b of all components of a. | |
template<typename T> | |
Vector2D< T > | operator* (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
muliply all components of a by b | |
template<typename T> | |
Vector2D< T > | operator/ (const Vector2D< T > &a, typename Vector2D< T >::TParam b) |
divide all components of a by b | |
template<typename T> | |
Vector2D< T > | operator+ (typename Vector2D< T >::TParam a, const Vector2D< T > &b) |
add a to all components of b | |
template<typename T> | |
Vector2D< T > | operator- (typename Vector2D< T >::TParam a, const Vector2D< T > &b) |
subtract a of all components of b | |
template<typename T> | |
Vector2D< T > | operator* (typename Vector2D< T >::TParam a, const Vector2D< T > &b) |
multiply all components of b with a | |
template<typename T> | |
Vector2D< T > | pointwiseMin (const Vector2D< T > &a, const Vector2D< T > &b) |
return a vector with, for each coordinate, the minimum value of a and b | |
template<typename T> | |
Vector2D< T > | pointwiseMax (const Vector2D< T > &a, const Vector2D< T > &b) |
return a vector with, for each coordinate, the maximum value of a and b | |
template<typename T> | |
Vector2D< T > | lerp (const Vector2D< T > &a, const Vector2D< T > &b, typename Vector2D< T >::TParam t) |
interpolate linearly between two vectors: a + t * (b - a) | |
template<typename T> | |
Vector3D< T >::TValue | dot (const Vector3D< T > &a, const Vector3D< T > &b) |
dot product. | |
template<typename T> | |
Vector3D< T > | cross (const Vector3D< T > &a, const Vector3D< T > &b) |
cross product | |
template<typename T> | |
Vector3D< T > | operator+ (const Vector3D< T > &a, const Vector3D< T > &b) |
componentwise addition | |
template<typename T> | |
Vector3D< T > | operator- (const Vector3D< T > &a, const Vector3D< T > &b) |
componentwise subtraction | |
template<typename T> | |
Vector3D< T > | operator* (const Vector3D< T > &a, const Vector3D< T > &b) |
Componentwise multiplication. | |
template<typename T> | |
Vector3D< T > | operator/ (const Vector3D< T > &a, const Vector3D< T > &b) |
Componentwise division. | |
template<typename T> | |
Vector3D< T > | operator+ (const Vector3D< T > &a, typename Vector3D< T >::TParam b) |
add b to all components of a. | |
template<typename T> | |
Vector3D< T > | operator- (const Vector3D< T > &a, typename Vector3D< T >::TParam b) |
subtract b of all components of a. | |
template<typename T> | |
Vector3D< T > | operator* (const Vector3D< T > &a, typename Vector3D< T >::TParam b) |
muliply all components of a by b | |
template<typename T> | |
Vector3D< T > | operator/ (const Vector3D< T > &a, typename Vector3D< T >::TParam b) |
divide all components of a by b | |
template<typename T> | |
Vector3D< T > | operator+ (typename Vector3D< T >::TParam a, const Vector3D< T > &b) |
add a to all components of b | |
template<typename T> | |
Vector3D< T > | operator- (typename Vector3D< T >::TParam a, const Vector3D< T > &b) |
subtract a of all components of b | |
template<typename T> | |
Vector3D< T > | operator* (typename Vector3D< T >::TParam a, const Vector3D< T > &b) |
multiply all components of b with a | |
template<typename T> | |
Vector3D< T > | pointwiseMin (const Vector3D< T > &a, const Vector3D< T > &b) |
return a vector with, for each coordinate, the minimum value of a and b | |
template<typename T> | |
Vector3D< T > | pointwiseMax (const Vector3D< T > &a, const Vector3D< T > &b) |
return a vector with, for each coordinate, the maximum value of a and b | |
template<typename T> | |
Vector3D< T > | lerp (const Vector3D< T > &a, const Vector3D< T > &b, typename Vector3D< T >::TParam t) |
interpolate linearly between two vectors: a + t * (b - a) | |
template<typename T> | |
Vector4D< T >::TValue | dot (const Vector4D< T > &a, const Vector4D< T > &b) |
dot product. | |
template<typename T> | |
Vector4D< T > | operator+ (const Vector4D< T > &a, const Vector4D< T > &b) |
componentwise addition | |
template<typename T> | |
Vector4D< T > | operator- (const Vector4D< T > &a, const Vector4D< T > &b) |
componentwise subtraction | |
template<typename T> | |
Vector4D< T > | operator* (const Vector4D< T > &a, const Vector4D< T > &b) |
Componentwise multiplication. | |
template<typename T> | |
Vector4D< T > | operator/ (const Vector4D< T > &a, const Vector4D< T > &b) |
Componentwise division. | |
template<typename T> | |
Vector4D< T > | operator+ (const Vector4D< T > &a, typename Vector4D< T >::TParam b) |
add b to all components of a. | |
template<typename T> | |
Vector4D< T > | operator- (const Vector4D< T > &a, typename Vector4D< T >::TParam b) |
subtract b of all components of a. | |
template<typename T> | |
Vector4D< T > | operator* (const Vector4D< T > &a, typename Vector4D< T >::TParam b) |
muliply all components of a by b | |
template<typename T> | |
Vector4D< T > | operator/ (const Vector4D< T > &a, typename Vector4D< T >::TParam b) |
divide all components of a by b | |
template<typename T> | |
Vector4D< T > | operator+ (typename Vector4D< T >::TParam a, const Vector4D< T > &b) |
add a to all components of b | |
template<typename T> | |
Vector4D< T > | operator- (typename Vector4D< T >::TParam a, const Vector4D< T > &b) |
subtract a of all components of b | |
template<typename T> | |
Vector4D< T > | operator* (typename Vector4D< T >::TParam a, const Vector4D< T > &b) |
multiply all components of b with a | |
template<typename T> | |
Vector4D< T > | pointwiseMin (const Vector4D< T > &a, const Vector4D< T > &b) |
return a vector with, for each coordinate, the minimum value of a and b | |
template<typename T> | |
Vector4D< T > | pointwiseMax (const Vector4D< T > &a, const Vector4D< T > &b) |
return a vector with, for each coordinate, the maximum value of a and b | |
template<typename T> | |
Vector4D< T > | lerp (const Vector4D< T > &a, const Vector4D< T > &b, typename Vector4D< T >::TParam t) |
interpolate linearly between two vectors: a + t * (b - a) | |
enumeration of clockwise versus counterclockwise
Enumerator | |
---|---|
oInvalid | invalid state |
oClockWise | clockwise orientation |
oCounterClockWise | counterclockwise orientation |
Definition at line 57 of file orientation.h.
enum lass::prim::Result |
meta information on the result you have from an operation like an intersection ...
If you want to find the intersection of two lines 'a' and 'b', you expect a point as result. However, that's not always true. 'a' and 'b' can be coincident so that all points of 'a' and 'b' are intersection points, or they could be not intersecting at all so that you don't have an intersection point. 'Result' will tell you this. In this same example, it will return rNone if the lines are not intersectiong, rOne if there is exactly one intersection point, and rInfinite if the lines are coincident.
Unlike lass::util::Side, results can't be OR'ed. Afterall, what would 'rNone | rOne' mean?
rInvalid is the invalid state of Result, if you encounter this, something is wrong. Notice the difference with rNone that is a valid state (although it says there's no answer).
enum lass::prim::Side |
Different sides of a surface.
Not all possibilities make sense for all surfaces. e.g. in case of a plane, only sFront, sSurface, sBack mean something, and in case of a sphere or bounding box you have sInside, sSurface, sOutside.
Side can be OR'ed, like (sFront | sBack) means in the front or in the back of the surface. However, return values of Side Foo::classify(const Bar& iBar) normally won't use this, and the equality test of this enums doesn't understand this neither (which is btw, a good thing). So if you try to do 'if (foo.classify(bar) == sFront | sBack)', this will always evaluate to false, no matter what the return value of classify is.
This is a simple workaround though. In many cases (sFont | sBack) means exaclty the same as !sSurface (OK OK WHAT I JUST HAVE WRITTEN HERE IS NONSES, but you get the idea :) So, if you want the above test to work, you should test for 'if (foo.classify(bar) != sSurface)'
In the future there will be another work around with bit and mask operations that will be available in the util namespace, but I still have to code these :D
bool lass::prim::triangulate | ( | const SimplePolygon2D< T, DegenerationPolicy > & | iPolygon, |
std::vector< Triangle2D< T > > & | oTriangles ) |
Definition at line 59 of file algorithm.h.
References triangulate().
Referenced by triangulate().
placement of foreground a in front of background b.
a is painted over b and leaves only a that part of b visible that isn't painted over: 1 - alphaA.
Definition at line 747 of file color_rgba.cpp.
Referenced by lass::io::Image::over(), and lass::io::Image::rover().
part of a inside b.
a is only painted where b is present, and b is not painted at all. This is the equivalent of only drawing clipped by the alpha channel of b
Definition at line 776 of file color_rgba.cpp.
Referenced by lass::io::Image::in(), and lass::io::Image::rin().
a held out by b, part of a outside b.
a is only painted where b is not present, and b is not painted at all. This is the equivalent of only drawing clipped by the inverse alpha channel of b.
Definition at line 800 of file color_rgba.cpp.
Referenced by lass::io::Image::out(), and lass::io::Image::rout().
union of a in b and b out a.
a atop b includes a where it's on top of b, otherwise it's b. But nothing outside b is included.
Definition at line 824 of file color_rgba.cpp.
Referenced by lass::io::Image::atop(), and lass::io::Image::ratop().
Definition at line 845 of file color_rgba.cpp.
Referenced by lass::io::Image::plus().
a seen through color filter b.
Definition at line 866 of file color_rgba.cpp.
Referenced by lass::io::Image::rthrough(), and lass::io::Image::through().
LASS_DLL ColorRGBA::TValue LASS_CALL lass::prim::distance | ( | const ColorRGBA & | a, |
const ColorRGBA & | b ) |
distance between non-non-premultiplied colours as 3D points (alpha channel is disregarded).
Definition at line 881 of file color_rgba.cpp.
References lass::num::sqr().