Struct AccelerationVector2
A 2D vector whose components represent acceleration, each expressed as an UnitsNet.Acceleration (e.g. metres per second squared).
Acceleration describes how quickly velocity is changing. In a game loop you often accumulate acceleration from forces (a = F / m) and integrate it over a time step to update velocity. It sits between JerkVector2 (rate of change of acceleration) and SpeedVector2 in the kinematics chain.
A common example is gravity: (0 m/s², −9.81 m/s²) pulls everything downward at 9.81 m/s² in the negative-Y direction. After 1 second, it adds −9.81 m/s to the Y component of velocity.
public readonly record struct AccelerationVector2 : IEquatable<AccelerationVector2>
- Implements
- Inherited Members
- Extension Methods
Examples
// Gravity in the negative-Y direction
var gravity = new AccelerationVector2(
Acceleration.Zero,
Acceleration.FromMetersPerSecondSquared(-9.81));
// Velocity gained after 0.5 s: v = a · t
SpeedVector2 dv = gravity * Duration.FromSeconds(0.5); // (0 m/s, −4.905 m/s)
Constructors
AccelerationVector2(Acceleration, Acceleration)
Constructs a AccelerationVector2 from two UnitsNet.Acceleration components.
public AccelerationVector2(Acceleration x, Acceleration y)
Parameters
xAccelerationThe X component.
yAccelerationThe Y component.
Properties
Magnitude
Returns the Euclidean magnitude of this vector as a UnitsNet.Acceleration. The result is expressed in the same unit as the X component.
public Acceleration Magnitude { get; }
Property Value
- Acceleration
X
The X component.
public Acceleration X { get; }
Property Value
- Acceleration
Y
The Y component.
public Acceleration Y { get; }
Property Value
- Acceleration
Zero
A AccelerationVector2 with both components set to zero.
public static AccelerationVector2 Zero { get; }
Property Value
Methods
Abs()
Returns a vector with each component replaced by its absolute value.
public AccelerationVector2 Abs()
Returns
- AccelerationVector2
A AccelerationVector2 with non-negative components.
Add(AccelerationVector2)
Adds two vectors component-wise.
public AccelerationVector2 Add(AccelerationVector2 other)
Parameters
otherAccelerationVector2The vector to add.
Returns
- AccelerationVector2
The component-wise sum.
ApproximatelyEquals(AccelerationVector2, Acceleration)
Returns true if each component of this vector is within
tolerance of the corresponding component of other.
public bool ApproximatelyEquals(AccelerationVector2 other, Acceleration tolerance)
Parameters
otherAccelerationVector2The vector to compare against.
toleranceAccelerationThe maximum allowed difference per component (inclusive).
Returns
As(AccelerationUnit)
Projects both components into the requested unit, returning a unit-less DoubleVector2.
public DoubleVector2 As(AccelerationUnit unit)
Parameters
unitAccelerationUnitThe target unit for each component.
Returns
- DoubleVector2
A DoubleVector2 with components expressed in
unit.
AsDefault()
Returns both components expressed in the SI base unit as a DoubleVector2.
public DoubleVector2 AsDefault()
Returns
- DoubleVector2
A DoubleVector2 with components in the default SI unit.
Clamp(AccelerationVector2, AccelerationVector2)
Returns a vector with each component clamped to the range [min, max].
public AccelerationVector2 Clamp(AccelerationVector2 min, AccelerationVector2 max)
Parameters
minAccelerationVector2The lower bound vector (inclusive, per component).
maxAccelerationVector2The upper bound vector (inclusive, per component).
Returns
- AccelerationVector2
A AccelerationVector2 with each component in [min, max].
Divide(double)
Divides the vector by a scalar divisor.
public AccelerationVector2 Divide(double scalar)
Parameters
scalardoubleThe scalar divisor.
Returns
- AccelerationVector2
The divided vector.
Equals(AccelerationVector2)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(AccelerationVector2 other)
Parameters
otherAccelerationVector2An object to compare with this object.
Returns
FromCentimetersPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromCentimetersPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromCentimetersPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromDecimetersPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromDecimetersPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromDecimetersPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromFeetPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromFeetPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromFeetPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromInchesPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromInchesPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromInchesPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromKilometersPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromKilometersPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromKilometersPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromKnotsPerHour(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromKnotsPerHour(UnitsNet.QuantityValue).
public static AccelerationVector2 FromKnotsPerHour(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromKnotsPerMinute(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromKnotsPerMinute(UnitsNet.QuantityValue).
public static AccelerationVector2 FromKnotsPerMinute(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromKnotsPerSecond(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromKnotsPerSecond(UnitsNet.QuantityValue).
public static AccelerationVector2 FromKnotsPerSecond(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromMetersPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromMetersPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromMetersPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromMicrometersPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromMicrometersPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromMicrometersPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromMillimetersPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromMillimetersPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromMillimetersPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromMillistandardGravity(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromMillistandardGravity(UnitsNet.QuantityValue).
public static AccelerationVector2 FromMillistandardGravity(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromNanometersPerSecondSquared(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromNanometersPerSecondSquared(UnitsNet.QuantityValue).
public static AccelerationVector2 FromNanometersPerSecondSquared(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
FromStandardGravity(double, double)
Creates a AccelerationVector2 with both components created via UnitsNet.Acceleration.FromStandardGravity(UnitsNet.QuantityValue).
public static AccelerationVector2 FromStandardGravity(double x, double y)
Parameters
Returns
- AccelerationVector2
A AccelerationVector2 with both components in the corresponding unit.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Lerp(AccelerationVector2, AccelerationVector2, double)
Linearly interpolates between two vectors.
The result at t = 0 is a; at t = 1 it is
b. Values of t outside [0, 1] extrapolate beyond the
endpoints — use LerpClamped(AccelerationVector2, AccelerationVector2, double) if you need the result bounded to the segment
between a and b.
public static AccelerationVector2 Lerp(AccelerationVector2 a, AccelerationVector2 b, double t)
Parameters
aAccelerationVector2The start vector (
t= 0).bAccelerationVector2The end vector (
t= 1).tdoubleThe interpolation parameter. Values outside [0, 1] extrapolate.
Returns
- AccelerationVector2
The interpolated AccelerationVector2.
LerpClamped(AccelerationVector2, AccelerationVector2, double)
Linearly interpolates between two vectors, with t clamped to [0, 1].
public static AccelerationVector2 LerpClamped(AccelerationVector2 a, AccelerationVector2 b, double t)
Parameters
aAccelerationVector2The start vector (
t= 0).bAccelerationVector2The end vector (
t= 1).tdoubleThe interpolation parameter, clamped to [0, 1].
Returns
- AccelerationVector2
The interpolated AccelerationVector2, always between
aandb.
Multiply(double)
Scales the vector by a scalar factor.
public AccelerationVector2 Multiply(double scalar)
Parameters
scalardoubleThe scalar factor.
Returns
- AccelerationVector2
The scaled vector.
Negate()
Negates both components.
public AccelerationVector2 Negate()
Returns
- AccelerationVector2
A vector with all components negated.
Normalize()
Returns a dimensionless unit vector pointing in the same direction. For a zero vector, Zero is returned.
public DoubleVector2 Normalize()
Returns
- DoubleVector2
A unit-length DoubleVector2 in the same direction.
Subtract(AccelerationVector2)
Subtracts two vectors component-wise.
public AccelerationVector2 Subtract(AccelerationVector2 other)
Parameters
otherAccelerationVector2The vector to subtract.
Returns
- AccelerationVector2
The component-wise difference.
Operators
operator +(AccelerationVector2, AccelerationVector2)
Adds two vectors component-wise.
public static AccelerationVector2 operator +(AccelerationVector2 left, AccelerationVector2 right)
Parameters
leftAccelerationVector2The left operand.
rightAccelerationVector2The right operand.
Returns
- AccelerationVector2
The component-wise sum.
operator /(AccelerationVector2, double)
Divides the vector by a scalar divisor.
public static AccelerationVector2 operator /(AccelerationVector2 left, double scalar)
Parameters
leftAccelerationVector2The vector to divide.
scalardoubleThe scalar divisor.
Returns
- AccelerationVector2
The divided vector.
operator /(AccelerationVector2, Duration)
Divides a AccelerationVector2 by a UnitsNet.Duration to produce a JerkVector2.
public static JerkVector2 operator /(AccelerationVector2 left, Duration right)
Parameters
leftAccelerationVector2The left operand.
rightDurationThe right operand.
Returns
operator *(double, AccelerationVector2)
Scales the vector by a scalar factor. Operands may be supplied in either order.
public static AccelerationVector2 operator *(double scalar, AccelerationVector2 right)
Parameters
scalardoubleThe scalar factor.
rightAccelerationVector2The vector to scale.
Returns
- AccelerationVector2
The scaled vector.
operator *(AccelerationVector2, double)
Scales the vector by a scalar factor.
public static AccelerationVector2 operator *(AccelerationVector2 left, double scalar)
Parameters
leftAccelerationVector2The vector to scale.
scalardoubleThe scalar factor.
Returns
- AccelerationVector2
The scaled vector.
operator *(AccelerationVector2, Duration)
Multiplies a AccelerationVector2 by a UnitsNet.Duration to produce a SpeedVector2.
public static SpeedVector2 operator *(AccelerationVector2 left, Duration right)
Parameters
leftAccelerationVector2The left operand.
rightDurationThe right operand.
Returns
operator *(AccelerationVector2, Mass)
Multiplies a AccelerationVector2 by a UnitsNet.Mass to produce a ForceVector2.
public static ForceVector2 operator *(AccelerationVector2 left, Mass right)
Parameters
leftAccelerationVector2The left operand.
rightMassThe right operand.
Returns
operator *(Duration, AccelerationVector2)
Multiplies a UnitsNet.Duration by a AccelerationVector2 to produce a SpeedVector2. Operands may be supplied in either order.
public static SpeedVector2 operator *(Duration left, AccelerationVector2 right)
Parameters
leftDurationThe left operand.
rightAccelerationVector2The right operand.
Returns
operator *(Mass, AccelerationVector2)
Multiplies a UnitsNet.Mass by a AccelerationVector2 to produce a ForceVector2. Operands may be supplied in either order.
public static ForceVector2 operator *(Mass left, AccelerationVector2 right)
Parameters
leftMassThe left operand.
rightAccelerationVector2The right operand.
Returns
operator -(AccelerationVector2, AccelerationVector2)
Subtracts two vectors component-wise.
public static AccelerationVector2 operator -(AccelerationVector2 left, AccelerationVector2 right)
Parameters
leftAccelerationVector2The left operand.
rightAccelerationVector2The right operand.
Returns
- AccelerationVector2
The component-wise difference.
operator -(AccelerationVector2)
Negates both components.
public static AccelerationVector2 operator -(AccelerationVector2 value)
Parameters
valueAccelerationVector2The vector to negate.
Returns
- AccelerationVector2
A vector with all components negated.