The class representing a point in 2-dimensional space.

Hierarchy (View Summary)

Constructors

Properties

x: number

X coordinate of a vector

y: number

Y coordinate of a vector

EMPTY: Readonly<AcGeVector2d> = ...

Accessors

  • get height(): number
  • Alias for y.

    Returns number

  • set height(value: number): void
  • Parameters

    • value: number

    Returns void

  • get width(): number
  • Alias for x.

    Returns number

  • set width(value: number): void
  • Parameters

    • value: number

    Returns void

Methods

  • Compute the angle in radians of this vector with respect to the positive x-axis.

    Returns number

    Return the angle in radians of this vector with respect to the positive x-axis.

  • If this vector's length is greater than the max value, it is replaced by the max value. If this vector's length is less than the min value, it is replaced by the min value.

    Parameters

    • min: number

      Input the minimum value the length will be clamped to

    • max: number

      Input the maximum value the length will be clamped to

    Returns AcGePoint2d

    Return this vector

  • If this vector's x or y values are greater than the max value, they are replaced by the max value. If this vector's x or y values are less than the min value, they are replaced by the min value.

    Parameters

    • minVal: number

      Input the minimum value the components will be clamped to

    • maxVal: number

      Input the maximum value the length will be clamped to

    Returns AcGePoint2d

    Return this vector

  • Calculate the cross product of this vector and v. Note that a 'cross-product' in 2D is not well-defined. This function computes a geometric cross-product often used in 2D graphics.

    Parameters

    Returns number

    Return the cross product of this vector and v.

  • Compute the squared distance from this vector to v. If you are just comparing the distance with another distance, you should compare the distance squared instead as it is slightly more efficient to calculate.

    Parameters

    Returns number

    Return the squared distance from this vector to v.

  • Return true if the components of this vector and v are strictly equal; false otherwise.

    Parameters

    Returns boolean

    Return true if the components of this vector and v are strictly equal; false otherwise.

  • Set this vector's x value to be array[ offset ] and y value to be array[ offset + 1 ].

    Parameters

    • array: number[]

      Input the source array.

    • offset: number = 0

      Input (optional) offset into the array. Default is 0.

    Returns AcGePoint2d

    Return this vector

  • If index equals 0 returns the x value. If index equals 1 returns the y value.

    Parameters

    • index: number

      0 or 1.

    Returns number

    Return this matrix

  • Compute the Euclidean length (straight-line length) from (0, 0) to (x, y).

    Returns number

    Return the Euclidean length (straight-line length) from (0, 0) to (x, y).

  • Compute the square of the Euclidean length (straight-line length) from (0, 0) to (x, y). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.

    Returns number

    Return the square of the Euclidean length (straight-line length) from (0, 0) to (x, y)

  • Linearly interpolates between this vector and v, where alpha is the percent distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.

    Parameters

    • v: AcGeVector2d

      Input 2d vector to interpolate towards.

    • alpha: number

      Input interpolation factor, typically in the closed interval [0, 1].

    Returns AcGePoint2d

    Return this vector

  • Return an array [x, y], or copies x and y into the provided array.

    Parameters

    • array: number[] = []

      Input (optional) array to store this vector to. If this is not provided, a new array will be created.

    • offset: number = 0

      Input (optional) optional offset into the array.

    Returns number[]

    Return an array [x, y], or copies x and y into the provided array.

  • Convert one point array to one number array

    Parameters

    Returns number[]

    Return converted number array