Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::Force2D Struct Reference

Directional force represented by direction and magnitude. More...

#include <spk_force_2d.hpp>

Collaboration diagram for spk::Force2D:
Collaboration graph

Public Member Functions

 Force2D ()=default
 Creates a zero force.
 Force2D (const spk::Vector2 &p_direction, const float &p_magnitude)
 Creates a force from direction and magnitude.
spk::Vector2 vector () const
 Returns the force vector.

Static Public Member Functions

static Force2D fromVector (const spk::Vector2 &p_vector)
 Builds a force from a vector.

Public Attributes

spk::Vector2 direction = {0.0f, 0.0f}
 Normalized direction of the force.
float magnitude = 0.0f
 Force magnitude.

Detailed Description

Directional force represented by direction and magnitude.

Constructor & Destructor Documentation

◆ Force2D()

spk::Force2D::Force2D ( const spk::Vector2 & p_direction,
const float & p_magnitude )
inline

Creates a force from direction and magnitude.

Parameters
p_directionUnit direction of the force.
p_magnitudeMagnitude of the force.

Member Function Documentation

◆ fromVector()

Force2D spk::Force2D::fromVector ( const spk::Vector2 & p_vector)
inlinestatic

Builds a force from a vector.

Parameters
p_vectorVector whose length becomes magnitude.
Returns
Force representing the same vector.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector()

spk::Vector2 spk::Force2D::vector ( ) const
inline

Returns the force vector.

Returns
Direction multiplied by magnitude.
Here is the caller graph for this function:

The documentation for this struct was generated from the following file: