Triangle
public struct Triangle<Vector> : GeometricType where Vector : VectorType
extension Triangle: BoundableType where Vector: VectorComparable
Represents a [triangle] as a trio of N-dimensional vectors which describe a 2-dimensional enclosed surface on an euclidean space.
-
Convenience for
Vector.Scalar
Declaration
Swift
public typealias Scalar = Vector.Scalar
-
The first point of this triangle.
Declaration
Swift
public var a: Vector
-
The second point of this triangle.
Declaration
Swift
public var b: Vector
-
The third point of this triangle.
Declaration
Swift
public var c: Vector
-
Declaration
Swift
public init(a: Vector, b: Vector, c: Vector)
-
Defines the normalized barycentric coordinates for a
See moreTriangle
.Declaration
Swift
struct Coordinates : Equatable
-
Declaration
Swift
var lineAB: LineSegment<Vector> { get }
-
Declaration
Swift
var lineAC: LineSegment<Vector> { get }
-
Declaration
Swift
var lineBC: LineSegment<Vector> { get }
-
Declaration
Swift
var lineBA: LineSegment<Vector> { get }
-
Declaration
Swift
var lineCA: LineSegment<Vector> { get }
-
Declaration
Swift
var lineCB: LineSegment<Vector> { get }
-
Projects the given barycentric coordinates back into world space.
Declaration
Swift
@inlinable public func projectToWorld(_ proj: Coordinates) -> Vector
-
Declaration
Swift
public var bounds: AABB<Vector> { get }
-
Returns the geometric center of this triangle.
Equivalent to the arithmetic mean of the three points of this triangle:
(a + b + c) / 3
Declaration
Swift
var center: Vector { get }
-
Returns the positive area of this triangle.
Performs the following operation:
1÷2 √(|AB|² |AC|² - (AB • AC)²)
Where
AB
is the vector going froma
tob
, andAC
froma
toc
:let AB = a - b let AC = a - c
(the area of the triangle is half of the area of the parallelogram formed by the vectors AB / AC on the plane of those vertices).
Triangles with internal angles of 0° or 180° have an area of zero.
Declaration
Swift
@inlinable var area: Scalar { get }