Copyright © 2021 by K4.org
  (v.0.48.124)

Vector is a pure geometry object. It is used for geometric computations within rules. It is based on the three.js Vector3 object.

Hierarchy

Implements

  • IKnown

Index

Accessors

length

length:

Returns the magnitude of the this vector.

x

x:

Returns the x magnitude of this vector in world coordinates.

y

y:

Returns the y magnitude of this vector in world coordinates.

z

z:

Returns the z magnitude of this vector in world coordinates.

Methods

addp

  • Add point to this, returning a new point

    Parameters

    • point: Point

      Point to add

    Returns Point

addv

  • Add vector to this, returning a new vector.

    Parameters

    • vector: Vector

      Vector to add

    Returns Vector

angleTo

  • Returns the angle in degrees, between this and vector. If normal is supplied, then will return the signed angle, from this to vector, about the normal, using the Right-Hand-Rule. The vectors do not need to be normalized.

    example
    this.unitX.angleTo(this.unitY) => 90
    this.unitX.angleTo(this.unitY, this.unitZ) => 90
    this.unitX.angleTo(v(1,-1,0), this.unitZ) => -45
    

    Parameters

    • vector: Vector

      The vector to measure to.

    • Optional normal: Vector

      Optional. A vector approximately perpendicular to the others, which determines the sign of the result.

    Returns number

    An angle in degrees.

cross

  • Cross vector with this, returning a new vector.

    Parameters

    • vector: Vector

      Vector to cross

    Returns Vector

describe

  • describe(): string
  • Returns a string of the form 'v<x, y, z>' where x, y, and z are in world coordinates. Note that these values are for display only, and are not guaranteed to reproduce the vector if read back in.

    Returns string

dot

  • Dot vector with this, returning a scalar.

    Parameters

    • vector: Vector

      vector to take the dot product with

    Returns number

get3

  • get3(): Vector3
  • Returns the three.js implementation object

    Returns Vector3

localX

  • localX(localFrame?: Frame): number
  • Returns the x-component of this relative to localFrame.

    example

    v(x,y,z).localX() => x

    Parameters

    • Optional localFrame: Frame

      The Frame in which we want the x-component

    Returns number

localY

  • localY(localFrame?: Frame): number
  • Returns the y-component of this relative to localFrame.

    example

    v(x,y,z).localY() => y

    Parameters

    • Optional localFrame: Frame

      The Frame in which we want the y-component

    Returns number

localZ

  • localZ(localFrame?: Frame): number
  • Returns the z-component of this relative to localFrame.

    example

    v(x,y,z).localZ() => z

    Parameters

    • Optional localFrame: Frame

      The Frame in which we want the z-component

    Returns number

near

  • Return true if the two vectors are "close" to pointing in the same direction, in the AAA test sense (1/64 @ length 1).

    Parameters

    Returns boolean

negate

  • Returns this negated as a new Vector

    Returns Vector

parallel

  • parallel(v: Vector): boolean
  • Return true if the two vectors are parallel to each other. They can be pointing in opposite directions.

    Parameters

    Returns boolean

rotate

  • Rotates a vector around an axis

    Parameters

    • angle: number

      rotation angle in degrees

    • axis: Vector

      vector about which to rotate

    Returns Vector

same

  • Returns true if the two vectors are within lengthEpsilon of each other

    Parameters

    Returns boolean

same3

  • same3(x: number, y: number, z: number): boolean
  • Returns true if the two vectors are within lengthEpsilon of each other

    Parameters

    • x: number

      Coordinate

    • y: number

      Coordinate

    • z: number

      Coordinate

    Returns boolean

scale

  • Return this multiplied by s in a new Vector

    Parameters

    • s: number

      Scale factor

    Returns Vector

unitize

  • Returns this vector normalized to length 1 in a new Vector

    Returns Vector

xform

  • Returns the vector transformed by f

    Parameters

    • f: Frame

      Frame to transform by

    Returns Vector