Ray (struct)¶
The Ray type represents linear 3D ray. This is expressed by a start and direction Vec3
/*
** Example: Ray
*/
Ray ray(Vec3(0.0, 0.0, 0.0), Vec3(0.1, -1.0, 0.4));
Methods¶
Ray ( in Ray other ) | |
Ray ( in Vec3 start, in Vec3 direction ) | |
Ray () | |
Ray | clone ? () |
Scalar | distanceToPoint ? ( in Vec3 point, out Scalar rayParam ) |
UInt32 | hash ? () |
Boolean | intersectBoundingBox ? ( in Box3 box3 ) |
Vec2 | intersectLine ? ( in Vec3 lineP0, in Vec3 lineP1 ) |
Boolean | intersectLineSegment ? ( in Vec3 lineP0, in Vec3 lineP1, out Scalar dist, out Scalar rayParam, out Scalar segmentParam ) |
Scalar | intersectPlane ? ( in Vec3 planePoint, in Vec3 planeNormal ) |
Vec3 | intersectPlaneVec3 ? ( in Vec3 planePoint, in Vec3 planeNormal ) |
Boolean | intersectTriangle ? ( in Boolean cull, in Boolean bidirectional, in Vec3 v0, in Vec3 v1, in Vec3 v2, out Vec3 point, out Scalar dist, out Scalar u, out Scalar v ) |
Vec3 | pointFromFactor ? ( in Scalar factor ) |
set ! ( in Vec3 start, in Vec3 direction ) |
Methods in detail¶
copy constructor
Ray ( in Vec3 start, in Vec3 direction )
Default constructor from two Vec3s
Ray ()
default constructor
clone method
Scalar Ray.distanceToPoint? ( in Vec3 point, out Scalar rayParam )
Returns the distance from an point in 3d space to the the ray.
point | The 3d point to measure the distance to |
rayParam | Returns the factor value along the ray that was the closts ponit to the given point. |
Hash for this value
Boolean Ray.intersectBoundingBox? ( in Box3 box3 )
Computes the intersections between the Ray and a 3d bounding volume defined as a Box3. Returns true if a ray intersects the given box3.
注釈
This intersection test should be performed in bounding box space, removing the need for all the matrix > vector multiplications. If the box is transformed, apply the inverse of the transformation to the Ray value first.
Vec2 Ray.intersectLine? ( in Vec3 lineP0, in Vec3 lineP1 )
Measures the distance between the ray and an infinite line. Returns the ray factor and line factor as a Vec2 value.
lineP0 | the first point defining a point on the infinite line |
lineP1 | the second point defining a point on the infinite line |
Boolean Ray.intersectLineSegment? ( in Vec3 lineP0, in Vec3 lineP1, out Scalar dist, out Scalar rayParam, out Scalar segmentParam )
Measures the intersection between the ray and a line segment in 3d space. If the line segment is behind the Ray, the method returns False.
lineP0 | the start point in the line segment |
lineP1 | the end point in the line segment |
dist | Returns the distance between a point on the line sement, and a point along the ray. |
rayParam | returns the factor along the ray |
segmentParam | returns the fraction along the given line segment. |
Scalar Ray.intersectPlane? ( in Vec3 planePoint, in Vec3 planeNormal )
Computes the intersection of the ray and an infinite plane. Returns the factor along the ray of the intersection with a plane. -1 is returned if the ray is parallel to the plane or there is no intersection. the plane is defined as a point and a normal.
planePoint | The point defining the position of the infinite plane |
planeNormal | the normal of the infinite plane |
Vec3 Ray.intersectPlaneVec3? ( in Vec3 planePoint, in Vec3 planeNormal )
Overloaded inline returning the intersection point
Boolean Ray.intersectTriangle? ( in Boolean cull, in Boolean bidirectional, in Vec3 v0, in Vec3 v1, in Vec3 v2, out Vec3 point, out Scalar dist, out Scalar u, out Scalar v )
Computes the intersection of the Ray and a triangle in 3d space defined by 3 point values. Returns true if the ray intersects the triangle. with a triangle.
cull | determines wether the back face should be tested. |
v0 | The first point defining the 3d triangle |
v1 | The second point defining the 3d triangle |
v2 | The third point defining the 3d triangle |
point | returns the intersection point |
dist | returns the distance to the intersection |
u | the u barycentric coordinate on the triangle of the intersection |
v | the v barycentric coordinate on the triangle of the intersection |
Vec3 Ray.pointFromFactor? ( in Scalar factor )
Return the point along the ray given a factor
Ray.set! ( in Vec3 start, in Vec3 direction )
Setter from two Vec3s