Table of Contents

Struct ForceVector2

Namespace
Thunder.UnitsNET.Vectors
Assembly
Thunder.UnitsNET.Vectors.dll

A 2D vector whose components represent force, each expressed as a UnitsNet.Force (e.g. newtons, kilonewtons).

Force describes a push or pull applied to a body. In Newton's second law (F = m·a), dividing a force vector by a UnitsNet.Mass gives an AccelerationVector2. The dot product of a force vector with a displacement vector gives the work done (energy transferred).

public readonly record struct ForceVector2 : IEquatable<ForceVector2>
Implements
Inherited Members
Extension Methods

Examples

// Applied force and resulting acceleration (a = F / m)
var force = new ForceVector2(Force.FromNewtons(10), Force.FromNewtons(5));
AccelerationVector2 accel = force / Mass.FromKilograms(2); // (5 m/s², 2.5 m/s²)

Constructors

ForceVector2(Force, Force)

Constructs a ForceVector2 from two UnitsNet.Force components.

public ForceVector2(Force x, Force y)

Parameters

x Force

The X component.

y Force

The Y component.

Properties

Magnitude

Returns the Euclidean magnitude of this vector as a UnitsNet.Force. The result is expressed in the same unit as the X component.

public Force Magnitude { get; }

Property Value

Force

X

The X component.

public Force X { get; }

Property Value

Force

Y

The Y component.

public Force Y { get; }

Property Value

Force

Zero

A ForceVector2 with both components set to zero.

public static ForceVector2 Zero { get; }

Property Value

ForceVector2

Methods

Abs()

Returns a vector with each component replaced by its absolute value.

public ForceVector2 Abs()

Returns

ForceVector2

A ForceVector2 with non-negative components.

Add(ForceVector2)

Adds two vectors component-wise.

public ForceVector2 Add(ForceVector2 other)

Parameters

other ForceVector2

The vector to add.

Returns

ForceVector2

The component-wise sum.

ApproximatelyEquals(ForceVector2, Force)

Returns true if each component of this vector is within tolerance of the corresponding component of other.

public bool ApproximatelyEquals(ForceVector2 other, Force tolerance)

Parameters

other ForceVector2

The vector to compare against.

tolerance Force

The maximum allowed difference per component (inclusive).

Returns

bool

true when |X - other.X| <= tolerance and |Y - other.Y| <= tolerance.

As(ForceUnit)

Projects both components into the requested unit, returning a unit-less DoubleVector2.

public DoubleVector2 As(ForceUnit unit)

Parameters

unit ForceUnit

The 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(ForceVector2, ForceVector2)

Returns a vector with each component clamped to the range [min, max].

public ForceVector2 Clamp(ForceVector2 min, ForceVector2 max)

Parameters

min ForceVector2

The lower bound vector (inclusive, per component).

max ForceVector2

The upper bound vector (inclusive, per component).

Returns

ForceVector2

A ForceVector2 with each component in [min, max].

Divide(double)

Divides the vector by a scalar divisor.

public ForceVector2 Divide(double scalar)

Parameters

scalar double

The scalar divisor.

Returns

ForceVector2

The divided vector.

Dot(LengthVector2)

Returns the mechanical work done by this force over a displacement (W = F⃗ · d⃗), expressed as UnitsNet.Energy.

Work is only done by the component of force that is aligned with the direction of motion: W = |F| · |d| · cos(θ). A force perpendicular to the motion (e.g., gravity on a horizontally-moving object, or centripetal force on a circular path) does no work. Negative work means the force is opposing motion (e.g., friction, air resistance).

public Energy Dot(LengthVector2 other)

Parameters

other LengthVector2

The displacement vector over which the force is applied.

Returns

Energy

The work done in joules (J). Positive = force aids motion; negative = force opposes motion.

Examples

// A 100 N force rightward moves an object 5 m rightward
var force = new ForceVector2(Force.FromNewtons(100), Force.Zero);
Energy work = force.Dot(new LengthVector2(Length.FromMeters(5), Length.Zero)); // 500 J

// A 100 N force rightward while object moves diagonally (3 m right, 4 m up)
Energy partialWork = force.Dot(new LengthVector2(Length.FromMeters(3), Length.FromMeters(4))); // 300 J

Dot(SpeedVector2)

Returns the instantaneous mechanical power delivered by this force to an object moving at the given velocity (P = F⃗ · v⃗), expressed as UnitsNet.Power.

Power is the rate at which work is being done. Like the work dot-product above, only the component of force aligned with velocity contributes. A braking force opposing motion returns negative power (energy is being absorbed, not delivered).

public Power Dot(SpeedVector2 other)

Parameters

other SpeedVector2

The velocity vector of the object the force is acting on.

Returns

Power

The instantaneous power in watts (W). Positive = force is doing work on the object; negative = force is absorbing energy from the object.

Examples

// Engine thrust 500 N forward, vehicle moving at 20 m/s forward
var thrust   = new ForceVector2(Force.FromNewtons(500), Force.Zero);
var velocity = new SpeedVector2(Speed.FromMetersPerSecond(20), Speed.Zero);
Power power  = thrust.Dot(velocity); // 10 000 W = 10 kW

Equals(ForceVector2)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(ForceVector2 other)

Parameters

other ForceVector2

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

FromDecanewtons(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromDecanewtons(UnitsNet.QuantityValue).

public static ForceVector2 FromDecanewtons(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromDyne(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromDyne(UnitsNet.QuantityValue).

public static ForceVector2 FromDyne(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromKiloPonds(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromKiloPonds(UnitsNet.QuantityValue).

public static ForceVector2 FromKiloPonds(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromKilogramsForce(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromKilogramsForce(UnitsNet.QuantityValue).

public static ForceVector2 FromKilogramsForce(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromKilonewtons(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromKilonewtons(UnitsNet.QuantityValue).

public static ForceVector2 FromKilonewtons(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromKilopoundsForce(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromKilopoundsForce(UnitsNet.QuantityValue).

public static ForceVector2 FromKilopoundsForce(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromMeganewtons(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromMeganewtons(UnitsNet.QuantityValue).

public static ForceVector2 FromMeganewtons(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromMicronewtons(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromMicronewtons(UnitsNet.QuantityValue).

public static ForceVector2 FromMicronewtons(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromMillinewtons(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromMillinewtons(UnitsNet.QuantityValue).

public static ForceVector2 FromMillinewtons(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromNewtons(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromNewtons(UnitsNet.QuantityValue).

public static ForceVector2 FromNewtons(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromOunceForce(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromOunceForce(UnitsNet.QuantityValue).

public static ForceVector2 FromOunceForce(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromPoundals(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromPoundals(UnitsNet.QuantityValue).

public static ForceVector2 FromPoundals(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromPoundsForce(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromPoundsForce(UnitsNet.QuantityValue).

public static ForceVector2 FromPoundsForce(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromShortTonsForce(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromShortTonsForce(UnitsNet.QuantityValue).

public static ForceVector2 FromShortTonsForce(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 with both components in the corresponding unit.

FromTonnesForce(double, double)

Creates a ForceVector2 with both components created via UnitsNet.Force.FromTonnesForce(UnitsNet.QuantityValue).

public static ForceVector2 FromTonnesForce(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

ForceVector2

A ForceVector2 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(ForceVector2, ForceVector2, 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(ForceVector2, ForceVector2, double) if you need the result bounded to the segment between a and b.

public static ForceVector2 Lerp(ForceVector2 a, ForceVector2 b, double t)

Parameters

a ForceVector2

The start vector (t = 0).

b ForceVector2

The end vector (t = 1).

t double

The interpolation parameter. Values outside [0, 1] extrapolate.

Returns

ForceVector2

The interpolated ForceVector2.

LerpClamped(ForceVector2, ForceVector2, double)

Linearly interpolates between two vectors, with t clamped to [0, 1].

public static ForceVector2 LerpClamped(ForceVector2 a, ForceVector2 b, double t)

Parameters

a ForceVector2

The start vector (t = 0).

b ForceVector2

The end vector (t = 1).

t double

The interpolation parameter, clamped to [0, 1].

Returns

ForceVector2

The interpolated ForceVector2, always between a and b.

Multiply(double)

Scales the vector by a scalar factor.

public ForceVector2 Multiply(double scalar)

Parameters

scalar double

The scalar factor.

Returns

ForceVector2

The scaled vector.

Negate()

Negates both components.

public ForceVector2 Negate()

Returns

ForceVector2

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(ForceVector2)

Subtracts two vectors component-wise.

public ForceVector2 Subtract(ForceVector2 other)

Parameters

other ForceVector2

The vector to subtract.

Returns

ForceVector2

The component-wise difference.

Operators

operator +(ForceVector2, ForceVector2)

Adds two vectors component-wise.

public static ForceVector2 operator +(ForceVector2 left, ForceVector2 right)

Parameters

left ForceVector2

The left operand.

right ForceVector2

The right operand.

Returns

ForceVector2

The component-wise sum.

operator /(ForceVector2, double)

Divides the vector by a scalar divisor.

public static ForceVector2 operator /(ForceVector2 left, double scalar)

Parameters

left ForceVector2

The vector to divide.

scalar double

The scalar divisor.

Returns

ForceVector2

The divided vector.

operator /(ForceVector2, Mass)

Divides a ForceVector2 by a UnitsNet.Mass to produce a AccelerationVector2.

public static AccelerationVector2 operator /(ForceVector2 left, Mass right)

Parameters

left ForceVector2

The left operand.

right Mass

The right operand.

Returns

AccelerationVector2

A AccelerationVector2.

operator *(double, ForceVector2)

Scales the vector by a scalar factor. Operands may be supplied in either order.

public static ForceVector2 operator *(double scalar, ForceVector2 right)

Parameters

scalar double

The scalar factor.

right ForceVector2

The vector to scale.

Returns

ForceVector2

The scaled vector.

operator *(ForceVector2, double)

Scales the vector by a scalar factor.

public static ForceVector2 operator *(ForceVector2 left, double scalar)

Parameters

left ForceVector2

The vector to scale.

scalar double

The scalar factor.

Returns

ForceVector2

The scaled vector.

operator *(ForceVector2, Duration)

Multiplies a force vector by a duration to produce an impulse vector (J = F·Δt), preserving the caller's unit.

Impulse is the "dose" of force delivered over time. A small force applied for a long time can produce the same impulse — and therefore the same momentum change — as a large force applied briefly. The result unit is derived from the force component unit (e.g. kN × s = kN·s, lbf × s = lbf·s). Unmapped units fall back to N·s.

public static ImpulseVector2 operator *(ForceVector2 left, Duration right)

Parameters

left ForceVector2

The force vector.

right Duration

The duration over which the force is applied.

Returns

ImpulseVector2

The impulse vector (momentum change) in the unit matching the force component unit.

Examples

var drag = new ForceVector2(Force.FromNewtons(-50), Force.Zero);
ImpulseVector2 impulse = drag * Duration.FromSeconds(4); // (-200 N·s, 0)

// Unit-preserving: kN × s = kN·s
var thrust = new ForceVector2(Force.From(10, ForceUnit.Kilonewton), Force.Zero);
ImpulseVector2 j = thrust * Duration.FromSeconds(3); // (30 kN·s, 0)

operator *(Duration, ForceVector2)

Multiplies a duration by a force vector to produce an impulse vector (J = F·Δt). Operands may be supplied in either order.

public static ImpulseVector2 operator *(Duration left, ForceVector2 right)

Parameters

left Duration

The duration over which the force is applied.

right ForceVector2

The force vector.

Returns

ImpulseVector2

The impulse vector in the unit matching the force component unit.

operator -(ForceVector2, ForceVector2)

Subtracts two vectors component-wise.

public static ForceVector2 operator -(ForceVector2 left, ForceVector2 right)

Parameters

left ForceVector2

The left operand.

right ForceVector2

The right operand.

Returns

ForceVector2

The component-wise difference.

operator -(ForceVector2)

Negates both components.

public static ForceVector2 operator -(ForceVector2 value)

Parameters

value ForceVector2

The vector to negate.

Returns

ForceVector2

A vector with all components negated.

latest ▼