Vector

open class Vector

Represents a vector.

  • Initializes a new vector with start at (0,0)

    Declaration

    Swift

    public convenience init()

    Return Value

    The newly created Vector.

  • Initializes a new Vector with the specified start point.

    Declaration

    Swift

    public init(x: Double, y: Double)

    Parameters

    x

    The x-coordinate of this Vector’s start point.

    y

    The y-coordinate of this Vector’s start point.

    Return Value

    The newly created Vector.

  • Initializes a new Vector with the specified start and end points.

    Declaration

    Swift

    public init(p1: Point, p2: Point)

    Parameters

    p1

    The start point of this Vector.

    p2

    The end point of this Vector.

    Return Value

    The newly created Vector.

  • Undocumented

    Declaration

    Swift

    public init(p: Point)
  • Returns the Vector which turns 90 grads to the left measured from the perspective of the specified Vector.

    Declaration

    Swift

    public static func left(_ v: Vector) -> Vector

    Parameters

    v

    The Vector whose perspective is considered.

    Return Value

    The resulting Vector.

  • Returns the Vector which turns 90 grads to the right measured from the perspective of the specified Vector.

    Declaration

    Swift

    public static func right(_ v: Vector) -> Vector

    Parameters

    v

    The Vector whose perspective is considered.

    Return Value

    The resulting Vector.

  • Calculates the multiplication Vector if the specified two Vector-s.

    Declaration

    Swift

    public static func multiply(_ vector1: Vector, vector2: Vector) -> Double

    Parameters

    vector1

    The first Vector.

    vector2

    The second Vector.

    Return Value

    A double, which represents the multiplication of the two Vector-s.

  • Multiplies the specified Vector by the specified scalar.

    Declaration

    Swift

    public static func multiply(_ vector: Vector, scalar: Double) -> Vector

    Parameters

    vector

    The Vector to multiply.

    scalar

    The scalar by which the vector is multiplied.

    Return Value

    The result of the multiplication of the Vector with the scalar.

  • Multiplies the specified scalar by the specified Vector.

    Declaration

    Swift

    public static func multiply(_ scalar: Double, vector: Vector) -> Vector

    Parameters

    scalar

    The scalar to multiply.

    vector

    The Vector by which the scalar is multiplied.

    Return Value

    The result of the multiplication of the scalar with the Vector.

  • x

    Specifies the x-coordinate of this Vector.

    Declaration

    Swift

    open var x: Double
  • y

    Specifies the y-coordinate of this Vector.

    Declaration

    Swift

    open var y: Double
  • Specifies the length-coordinate of this Vector.

    Declaration

    Swift

    open var length: Double { get }