Class: Velocity

rune.physics.Velocity(x, y)

The Velocity class represents motion in two dimensions (x and y).

Constructor

new Velocity(x, y)

Creates a new Velocity object.
Parameters:
Name Type Description
x number Velocity in x direction.
y number Velocity in y direction.
Source:

Extends

Members

acceleration :rune.geom.Vector2D

Acceleration acts as gravity; it is a constant force that can affect the object in the x and / or y direction. If acceleration is set, the object is moved by the force of acceleration for each update.
Type:
Default Value:
  • new rune.geom.Vector2D(0, 0)
Source:

angular :number

The object's rotation speed, stated in degrees per tick / frame.
Type:
  • number
Default Value:
  • 0.0
Source:

angularAcceleration :number

Constant force that affects the object's rotation, this property basically acts as gravity for rotation. If the property is set, the object is forced to rotate.
Type:
  • number
Default Value:
  • 0.0
Source:

angularDrag :number

Force that counteracts the rotational velocity when the rotation lacks acceleration, ie force that slows down the rotation.
Type:
  • number
Default Value:
  • 0.0
Source:

angularMax :number

Limits rotation to a maximum speed.
Type:
  • number
Default Value:
  • 100
Source:

drag :rune.geom.Vector2D

Power that counteracts the velocity of the object. This force is applied only when the object is not accelerating. If set, the object loses its velocity over time.
Type:
Default Value:
  • new rune.geom.Vector2D(0, 0)
Source:

max :rune.geom.Vector2D

Limits the velocity of the object in the x and y direction to a maximum value.
Type:
Default Value:
  • new rune.geom.Vector2D(100, 100)
Source:

x :number

The horizontal coordinate of the point. The default value is 0.
Type:
  • number
Overrides:
Source:

y :number

The vertical coordinate of the point. The default value is 0.
Type:
  • number
Overrides:
Source:

Methods

abs() → {rune.geom.Vector2D}

Set the vector axes values to absolute values.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

add(vector) → {rune.geom.Vector2D}

Adds the argument vector to this vector.
Parameters:
Name Type Description
vector rune.geom.Vector2D The second vector.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

cross(vector) → {number}

Returns the cross product of this vector by another.
Parameters:
Name Type Description
vector rune.geom.Vector2D The second vector.
Inherited From:
Source:
Returns:
Type
number

distance(point) → {number}

Returns the distance between the current and specified point.
Parameters:
Name Type Description
point rune.geom.Point The specified point.
Inherited From:
Source:
Returns:
Type
number

divide(value) → {rune.geom.Vector2D}

Divides this vector by another vector, or by a number specified as a floating point number.
Parameters:
Name Type Description
value rune.geom.Vector2D | number The value to divide by.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

dot(vector) → {number}

Returns the dot product of this vector by another.
Parameters:
Name Type Description
vector rune.geom.Vector2D The second vector.
Inherited From:
Source:
Returns:
Type
number

equals(vector) → {boolean}

Determine if the specified vector is equal to the current vector.
Parameters:
Name Type Description
vector rune.geom.Vector2D The second vector.
Inherited From:
Source:
Returns:
Type
boolean

interpolate(point, fractionopt, outputopt) → {rune.geom.Point}

Determines a point between two specified points. The parameter fraction determines where the new interpolated point is located relative to the two end points.
Parameters:
Name Type Attributes Description
point rune.geom.Point The second point.
fraction number <optional>
The level of interpolation between the two points.
output rune.geom.Point <optional>
Save results to this object.
Inherited From:
Source:
Returns:
The new, interpolated point.
Type
rune.geom.Point

magnitude(squaredopt) → {number}

Returns the magnitude (length) of this vector.
Parameters:
Name Type Attributes Description
squared boolean <optional>
Request squared magnitude.
Inherited From:
Source:
Returns:
Type
number

multiply(value) → {rune.geom.Vector2D}

Multiplies this vector by another vector, or by a number specified as a floating point number.
Parameters:
Name Type Description
value rune.geom.Vector2D | number The value to multiply by.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

normalize(scaleopt) → {rune.geom.Vector2D}

Scales the line segment between (0,0) and the current vector to a set length.
Parameters:
Name Type Attributes Description
scale number <optional>
The scaling value.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

reverse() → {rune.geom.Vector2D}

Reverses this vector i.e multiplies it by -1.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

rotate(rads) → {rune.geom.Vector2D}

Rotates the vector with specified radians.
Parameters:
Name Type Description
rads number Amount of rotation specified in radians.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

round(n) → {rune.geom.Vector2D}

Rotates the vector by provided radians.
Parameters:
Name Type Description
n number Number of decimals for precision.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

subtract(vector) → {rune.geom.Vector2D}

Subtracts the argument vector from this vector.
Parameters:
Name Type Description
vector rune.geom.Vector2D The second vector.
Inherited From:
Source:
Returns:
Type
rune.geom.Vector2D

toString() → {string}

Returns a string that contains the values of the x and y coordinates.
Inherited From:
Source:
Returns:
The string representation of the coordinates.
Type
string