Vector3

public struct Vector3<Scalar> : Vector3Type
extension Vector3: Equatable where Scalar: Equatable
extension Vector3: Hashable where Scalar: Hashable
extension Vector3: Encodable where Scalar: Encodable
extension Vector3: Decodable where Scalar: Decodable
extension Vector3: VectorComparable where Scalar: Comparable
extension Vector3: AdditiveArithmetic where Scalar: AdditiveArithmetic
extension Vector3: VectorAdditive where Scalar: AdditiveArithmetic
extension Vector3: VectorMultiplicative where Scalar: Numeric
extension Vector3: Vector3Additive where Scalar: AdditiveArithmetic
extension Vector3: Vector3Multiplicative where Scalar: Numeric
extension Vector3: VectorSigned where Scalar: SignedNumeric & Comparable
extension Vector3: VectorDivisible where Scalar: DivisibleArithmetic
extension Vector3: VectorFloatingPoint where Scalar: DivisibleArithmetic & FloatingPoint
extension Vector3: SignedDistanceMeasurableType where Scalar: DivisibleArithmetic & FloatingPoint
extension Vector3: Vector3FloatingPoint where Scalar: DivisibleArithmetic & FloatingPoint
extension Vector3: VectorReal where Scalar: DivisibleArithmetic & Real
extension Vector3: Vector3Real where Scalar: DivisibleArithmetic & Real

A three-component vector type

  • Declaration

    Swift

    public typealias SubVector3 = `Self`
  • x

    X coordinate of this vector

    Declaration

    Swift

    public var x: Scalar
  • y

    Y coordinate of this vector

    Declaration

    Swift

    public var y: Scalar
  • z

    Z coordinate of this vector

    Declaration

    Swift

    public var z: Scalar
  • Textual representation of this Vector3

    Declaration

    Swift

    public var description: String { get }
  • Declaration

    Swift

    public init(x: Scalar, y: Scalar, z: Scalar)
  • Declaration

    Swift

    public init(repeating scalar: Scalar)
  • Initializes this Vector3 with the values from a given tuple.

    Declaration

    Swift

    public init(_ tuple: (Scalar, Scalar, Scalar))

Available where Scalar: Comparable

  • Returns the pointwise minimal Vector where each component is the minimal scalar value at each index for both vectors.

    Declaration

    Swift

    public static func pointwiseMin(_ lhs: `Self`, _ rhs: `Self`) -> Vector3<Scalar>
  • Returns the pointwise maximal Vector where each component is the maximal scalar value at each index for both vectors.

    Declaration

    Swift

    public static func pointwiseMax(_ lhs: `Self`, _ rhs: `Self`) -> Vector3<Scalar>
  • Compares two vectors and returns true if all components of lhs are greater than rhs.

    Performs lhs.x > rhs.x && lhs.y > rhs.y && lhs.z > rhs.z

    Declaration

    Swift

    public static func > (lhs: `Self`, rhs: `Self`) -> Bool
  • Compares two vectors and returns true if all components of lhs are greater than or equal to rhs.

    Performs lhs.x >= rhs.x && lhs.y >= rhs.y && lhs.z >= rhs.z

    Declaration

    Swift

    public static func >= (lhs: `Self`, rhs: `Self`) -> Bool
  • Compares two vectors and returns true if all components of lhs are less than rhs.

    Performs lhs.x < rhs.x && lhs.y < rhs.y && lhs.z < rhs.z

    Declaration

    Swift

    public static func < (lhs: `Self`, rhs: `Self`) -> Bool
  • Compares two vectors and returns true if all components of lhs are less than or equal to rhs.

    Performs lhs.x <= rhs.x && lhs.y <= rhs.y && lhs.z <= rhs.z

    Declaration

    Swift

    public static func <= (lhs: `Self`, rhs: `Self`) -> Bool

Available where Scalar: AdditiveArithmetic

  • A zero-value Vector3 value where each component corresponds to its representation of 0.

    Declaration

    Swift

    public static var zero: `Self` { get }
  • Declaration

    Swift

    @inlinable
    public var nonZeroScalarCount: Int { get }
  • Declaration

    Swift

    public static func + (lhs: `Self`, rhs: `Self`) -> Vector3<Scalar>
  • Declaration

    Swift

    public static func - (lhs: `Self`, rhs: `Self`) -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func + (lhs: `Self`, rhs: Scalar) -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func - (lhs: `Self`, rhs: Scalar) -> Vector3<Scalar>

Available where Scalar: Numeric

  • one

    A unit-value Vector3Type value where each component corresponds to its representation of 1.

    Declaration

    Swift

    public static var one: `Self` { get }
  • Calculates the dot product between this and another provided Vector3Type

    Declaration

    Swift

    public func dot(_ other: `Self`) -> Scalar
  • Undocumented

    Declaration

    Swift

    public static func * (lhs: `Self`, rhs: `Self`) -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func * (lhs: `Self`, rhs: Scalar) -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func * (lhs: Scalar, rhs: `Self`) -> Vector3<Scalar>

Available where Scalar: SignedNumeric & Comparable

  • Returns a Vector3 where each component is the absolute value of the components of this Vector3.

    Declaration

    Swift

    public var absolute: `Self` { get }
  • Declaration

    Swift

    public var sign: `Self` { get }
  • Negates this Vector

    Declaration

    Swift

    public prefix static func - (lhs: `Self`) -> Vector3<Scalar>

Available where Scalar: DivisibleArithmetic

  • Undocumented

    Declaration

    Swift

    public static func / (lhs: `Self`, rhs: `Self`) -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func / (lhs: `Self`, rhs: Scalar) -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func / (lhs: Scalar, rhs: `Self`) -> Vector3<Scalar>

Available where Scalar: DivisibleArithmetic & FloatingPoint

  • Returns the result of adding the product of the two given vectors to this vector, computed without intermediate rounding.

    This method is equivalent to calling C fma function on each component.

    Declaration

    Swift

    public func addingProduct(_ a: `Self`, _ b: `Self`) -> Vector3<Scalar>

    Parameters

    lhs

    One of the vectors to multiply before adding to this vector.

    rhs

    The other vector to multiply.

    Return Value

    The product of lhs and rhs, added to this vector.

  • Returns the result of adding the product of the given scalar and vector to this vector, computed without intermediate rounding.

    This method is equivalent to calling C fma function on each component.

    Declaration

    Swift

    public func addingProduct(_ a: Scalar, _ b: `Self`) -> Vector3<Scalar>

    Parameters

    lhs

    A scalar to multiply before adding to this vector.

    rhs

    A vector to multiply.

    Return Value

    The product of lhs and rhs, added to this vector.

  • Returns the result of adding the product of the given vector and scalar to this vector, computed without intermediate rounding.

    This method is equivalent to calling C fma function on each component.

    Declaration

    Swift

    public func addingProduct(_ a: `Self`, _ b: Scalar) -> Vector3<Scalar>

    Parameters

    lhs

    A vector to multiply before adding to this vector.

    rhs

    A scalar to multiply.

    Return Value

    The product of lhs and rhs, added to this vector.

  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.

    Declaration

    Swift

    public func rounded(_ rule: FloatingPointRoundingRule) -> Vector3<Scalar>
  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.toNearestOrAwayFromZero.

    Equivalent to calling C’s round() function on each component.

    Declaration

    Swift

    public func rounded() -> Vector3<Scalar>
  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.up.

    Equivalent to calling C’s ceil() function on each component.

    Declaration

    Swift

    public func ceil() -> Vector3<Scalar>
  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.down.

    Equivalent to calling C’s floor() function on each component.

    Declaration

    Swift

    public func floor() -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func % (lhs: `Self`, rhs: `Self`) -> Vector3<Scalar>
  • Undocumented

    Declaration

    Swift

    public static func % (lhs: `Self`, rhs: Scalar) -> Vector3<Scalar>
  • Declaration

    Swift

    public func signedDistance(to other: `Self`) -> Scalar
  • Declaration

    Swift

    public init<V>(_ vec: V) where V : Vector3Type, V.Scalar : BinaryInteger

Available where Scalar: DivisibleArithmetic & Real

  • Declaration

    Swift

    public static func pow(_ vec: `Self`, _ exponent: Int) -> Vector3<Scalar>
  • Declaration

    Swift

    public static func pow(_ vec: `Self`, _ exponent: `Self`) -> Vector3<Scalar>
  • The XY-plane angle of this vector

    Declaration

    Swift

    public var azimuth: Scalar { get }
  • The elevation angle of this vector, or the angle between the XY plane and the vector.

    Returns zero, if the vector’s length is zero.

    Declaration

    Swift

    @inlinable
    public var elevation: Scalar { get }