Struct ImpulseVector2
A 2D vector whose components represent impulse, each expressed as an UnitsNet.Impulse (e.g. newton-seconds).
Impulse is the product of force and time (J = F·Δt). It equals the change in momentum of an object, making it useful for modelling collisions and sudden force applications in physics simulations.
public readonly record struct ImpulseVector2 : IEquatable<ImpulseVector2>
- Implements
- Inherited Members
- Extension Methods
Examples
var impulse = new ImpulseVector2(Impulse.FromNewtonSeconds(5), Impulse.Zero);
Constructors
ImpulseVector2(Impulse, Impulse)
Constructs a ImpulseVector2 from two UnitsNet.Impulse components.
public ImpulseVector2(Impulse x, Impulse y)
Parameters
xImpulseThe X component.
yImpulseThe Y component.
Properties
Magnitude
Returns the Euclidean magnitude of this vector as a UnitsNet.Impulse. The result is expressed in the same unit as the X component.
public Impulse Magnitude { get; }
Property Value
- Impulse
X
The X component.
public Impulse X { get; }
Property Value
- Impulse
Y
The Y component.
public Impulse Y { get; }
Property Value
- Impulse
Zero
A ImpulseVector2 with both components set to zero.
public static ImpulseVector2 Zero { get; }
Property Value
Methods
Abs()
Returns a vector with each component replaced by its absolute value.
public ImpulseVector2 Abs()
Returns
- ImpulseVector2
A ImpulseVector2 with non-negative components.
Add(ImpulseVector2)
Adds two vectors component-wise.
public ImpulseVector2 Add(ImpulseVector2 other)
Parameters
otherImpulseVector2The vector to add.
Returns
- ImpulseVector2
The component-wise sum.
ApproximatelyEquals(ImpulseVector2, Impulse)
Returns true if each component of this vector is within
tolerance of the corresponding component of other.
public bool ApproximatelyEquals(ImpulseVector2 other, Impulse tolerance)
Parameters
otherImpulseVector2The vector to compare against.
toleranceImpulseThe maximum allowed difference per component (inclusive).
Returns
As(ImpulseUnit)
Projects both components into the requested unit, returning a unit-less DoubleVector2.
public DoubleVector2 As(ImpulseUnit unit)
Parameters
unitImpulseUnitThe 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(ImpulseVector2, ImpulseVector2)
Returns a vector with each component clamped to the range [min, max].
public ImpulseVector2 Clamp(ImpulseVector2 min, ImpulseVector2 max)
Parameters
minImpulseVector2The lower bound vector (inclusive, per component).
maxImpulseVector2The upper bound vector (inclusive, per component).
Returns
- ImpulseVector2
A ImpulseVector2 with each component in [min, max].
Divide(double)
Divides the vector by a scalar divisor.
public ImpulseVector2 Divide(double scalar)
Parameters
scalardoubleThe scalar divisor.
Returns
- ImpulseVector2
The divided vector.
Equals(ImpulseVector2)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(ImpulseVector2 other)
Parameters
otherImpulseVector2An object to compare with this object.
Returns
FromCentinewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromCentinewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromCentinewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromDecanewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromDecanewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromDecanewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromDecinewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromDecinewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromDecinewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromKilogramMetersPerSecond(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromKilogramMetersPerSecond(UnitsNet.QuantityValue).
public static ImpulseVector2 FromKilogramMetersPerSecond(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromKilonewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromKilonewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromKilonewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromMeganewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromMeganewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromMeganewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromMicronewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromMicronewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromMicronewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromMillinewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromMillinewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromMillinewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromNanonewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromNanonewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromNanonewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromNewtonSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromNewtonSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromNewtonSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromPoundFeetPerSecond(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromPoundFeetPerSecond(UnitsNet.QuantityValue).
public static ImpulseVector2 FromPoundFeetPerSecond(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromPoundForceSeconds(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromPoundForceSeconds(UnitsNet.QuantityValue).
public static ImpulseVector2 FromPoundForceSeconds(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 with both components in the corresponding unit.
FromSlugFeetPerSecond(double, double)
Creates a ImpulseVector2 with both components created via UnitsNet.Impulse.FromSlugFeetPerSecond(UnitsNet.QuantityValue).
public static ImpulseVector2 FromSlugFeetPerSecond(double x, double y)
Parameters
Returns
- ImpulseVector2
A ImpulseVector2 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(ImpulseVector2, ImpulseVector2, 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(ImpulseVector2, ImpulseVector2, double) if you need the result bounded to the segment
between a and b.
public static ImpulseVector2 Lerp(ImpulseVector2 a, ImpulseVector2 b, double t)
Parameters
aImpulseVector2The start vector (
t= 0).bImpulseVector2The end vector (
t= 1).tdoubleThe interpolation parameter. Values outside [0, 1] extrapolate.
Returns
- ImpulseVector2
The interpolated ImpulseVector2.
LerpClamped(ImpulseVector2, ImpulseVector2, double)
Linearly interpolates between two vectors, with t clamped to [0, 1].
public static ImpulseVector2 LerpClamped(ImpulseVector2 a, ImpulseVector2 b, double t)
Parameters
aImpulseVector2The start vector (
t= 0).bImpulseVector2The end vector (
t= 1).tdoubleThe interpolation parameter, clamped to [0, 1].
Returns
- ImpulseVector2
The interpolated ImpulseVector2, always between
aandb.
Multiply(double)
Scales the vector by a scalar factor.
public ImpulseVector2 Multiply(double scalar)
Parameters
scalardoubleThe scalar factor.
Returns
- ImpulseVector2
The scaled vector.
Negate()
Negates both components.
public ImpulseVector2 Negate()
Returns
- ImpulseVector2
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(ImpulseVector2)
Subtracts two vectors component-wise.
public ImpulseVector2 Subtract(ImpulseVector2 other)
Parameters
otherImpulseVector2The vector to subtract.
Returns
- ImpulseVector2
The component-wise difference.
Operators
operator +(ImpulseVector2, ImpulseVector2)
Adds two vectors component-wise.
public static ImpulseVector2 operator +(ImpulseVector2 left, ImpulseVector2 right)
Parameters
leftImpulseVector2The left operand.
rightImpulseVector2The right operand.
Returns
- ImpulseVector2
The component-wise sum.
operator /(ImpulseVector2, double)
Divides the vector by a scalar divisor.
public static ImpulseVector2 operator /(ImpulseVector2 left, double scalar)
Parameters
leftImpulseVector2The vector to divide.
scalardoubleThe scalar divisor.
Returns
- ImpulseVector2
The divided vector.
operator *(double, ImpulseVector2)
Scales the vector by a scalar factor. Operands may be supplied in either order.
public static ImpulseVector2 operator *(double scalar, ImpulseVector2 right)
Parameters
scalardoubleThe scalar factor.
rightImpulseVector2The vector to scale.
Returns
- ImpulseVector2
The scaled vector.
operator *(ImpulseVector2, double)
Scales the vector by a scalar factor.
public static ImpulseVector2 operator *(ImpulseVector2 left, double scalar)
Parameters
leftImpulseVector2The vector to scale.
scalardoubleThe scalar factor.
Returns
- ImpulseVector2
The scaled vector.
operator -(ImpulseVector2, ImpulseVector2)
Subtracts two vectors component-wise.
public static ImpulseVector2 operator -(ImpulseVector2 left, ImpulseVector2 right)
Parameters
leftImpulseVector2The left operand.
rightImpulseVector2The right operand.
Returns
- ImpulseVector2
The component-wise difference.
operator -(ImpulseVector2)
Negates both components.
public static ImpulseVector2 operator -(ImpulseVector2 value)
Parameters
valueImpulseVector2The vector to negate.
Returns
- ImpulseVector2
A vector with all components negated.