Triangle3
public extension Triangle3 where Vector: Vector3Multiplicative
extension Triangle3: PlaneType where Vector: Vector3FloatingPoint
extension Triangle3: LineIntersectablePlaneType where Vector: Vector3FloatingPoint
extension Triangle3: SignedDistanceMeasurableType where Vector: Vector3FloatingPoint
-
Returns the cross product of the edges
BA
andCA
on this triangle.The resulting cross vector can be used to compute the area of the triangle, its normal, and its winding.
For a 3D triangle, the crossed area is computed as the cross-product of
BA
andCA
:let ba = b - a let ca = c - a return ba.cross(ca)
Seealso
signedArea
Declaration
Swift
var crossedArea: Vector { get }
-
Declaration
Swift
public var pointOnPlane: Vector { get }
-
Returns normal for this
Triangle3
. The direction of the normal depends on the winding ofa
->b
->c
. The normal is always pointing to the direction where the points form an anti-clockwise winding.Declaration
Swift
public var normal: Vector { get }
-
Returns the plane this
Triangle3
forms on 3D space, with the normal pointing to the winding betweena
->b
->c
.Declaration
Swift
public var asPlane: PointNormalPlane<Vector> { get }
-
Returns the normalized magnitude for a line’s intersection point on this triangle.
Result is
nil
if intersection is not within the line’s limits, the line is parallel to this triangle, or the intersection point is not within this triangle’s area.Declaration
Swift
@inlinable public func unclampedNormalMagnitudeForIntersection<Line: LineFloatingPoint>( with line: Line ) -> Vector.Scalar? where Line.Vector == Vector
-
Returns the result of a line intersection on this triangle.
Result is
nil
if intersection is not within the line’s limits, the line is parallel to this triangle, or the intersection point is not within this triangle’s area.Declaration
Swift
@inlinable public func intersection<Line: LineFloatingPoint>( with line: Line ) -> Vector? where Line.Vector == Vector
-
Performs Möller-Trumbore intersection algorithm against a line. Returns scalars for the line’s magnitude, and barycentric coordinates for the triangle’s position on the intersection.
Intersections that happen outside the line’s range (see
containsProjectedNormalizedMagnitude(_:)
) returnnil
, instead.Declaration
Swift
@inlinable public func mollerTrumboreIntersect<Line: LineFloatingPoint>( with line: Line ) -> (lineMagnitude: Scalar, Coordinates)? where Line.Vector == Vector
-
Performs a projection of a given set of coordinates onto this triangle as a set of barycentric coordinates.
Declaration
Swift
public func toBarycentric(x: Scalar, y: Scalar, z: Scalar) -> Coordinates
-
Performs a projection of a given vector onto this triangle as a set of barycentric coordinates.
The resulting coordinates might have scalar values
< .zero
, indicating points that projected outside the area of the triangle.The method assumes
vector
is coplanar witha
,b
, andc
.Declaration
Swift
@inlinable public func toBarycentric(_ vector: Vector) -> Coordinates
-
Declaration
Swift
public func signedDistance(to point: Vector) -> Vector.Scalar