JSim 2026.06.01-p(1)
Loading...
Searching...
No Matches
frcsim::MagnusModel Class Reference

Computes a Magnus lift force from linear velocity and spin. More...

#include <magnus_model.hpp>

Public Member Functions

 MagnusModel (double magnus_coefficient=1.0e-4)
 Creates a Magnus-force model with the given coefficient.
double magnusCoefficient () const
 Returns the current Magnus coefficient.
void setMagnusCoefficient (double coefficient)
 Updates the Magnus coefficient used by computeForce().
Vector3 computeForce (const Vector3 &velocity_mps, const Vector3 &spin_radps) const
 Computes the lift force produced by the supplied velocity and spin.

Detailed Description

Computes a Magnus lift force from linear velocity and spin.

This model is intentionally small: it just wraps the shared Vector3::magnusForce helper behind a configurable scalar coefficient so the same lift formulation can be reused by game-piece, shot, and simulation code without duplicating the cross-product math.

The input vectors use the world frame convention used throughout JSim and WPILib: +X points away from the blue alliance wall downfield, +Y points to the left when looking from the blue alliance end, and +Z points upward.

Constructor & Destructor Documentation

◆ MagnusModel()

frcsim::MagnusModel::MagnusModel ( double magnus_coefficient = 1.0e-4)
inlineexplicit

Creates a Magnus-force model with the given coefficient.

Parameters
magnus_coefficientScalar applied to the omega x v lift term. The default matches the rest of the physics code and is tuned for SI inputs (meters per second and radians per second).

Member Function Documentation

◆ computeForce()

Vector3 frcsim::MagnusModel::computeForce ( const Vector3 & velocity_mps,
const Vector3 & spin_radps ) const
inline

Computes the lift force produced by the supplied velocity and spin.

Parameters
velocity_mpsLinear velocity vector in meters per second, expressed in the world frame.
spin_radpsAngular velocity vector in radians per second, expressed in the same frame as velocity_mps. Both vectors must be expressed in the same reference frame, because the result is the cross product omega x v scaled by the model coefficient. The returned force uses the model F = k * (omega x v), where k is magnusCoefficient().
Returns
Magnus force vector in newtons.

◆ magnusCoefficient()

double frcsim::MagnusModel::magnusCoefficient ( ) const
inline

Returns the current Magnus coefficient.

◆ setMagnusCoefficient()

void frcsim::MagnusModel::setMagnusCoefficient ( double coefficient)
inline

Updates the Magnus coefficient used by computeForce().

Parameters
coefficientNew scalar multiplier for the lift term.

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