JSim 2026.06.01-p(1)
Loading...
Searching...
No Matches
magnus_model.hpp
Go to the documentation of this file.
1// Copyright (c) JSim contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the LGPLv3 license file in the root directory of this project.
4
5#pragma once
6
8
9namespace frcsim {
10
24 public:
31 explicit MagnusModel(double magnus_coefficient = 1.0e-4)
32 : magnus_coefficient_(magnus_coefficient) {}
33
35 double magnusCoefficient() const { return magnus_coefficient_; }
36
41 void setMagnusCoefficient(double coefficient) {
42 magnus_coefficient_ = coefficient;
43 }
44
57 Vector3 computeForce(const Vector3& velocity_mps,
58 const Vector3& spin_radps) const {
59 return Vector3::magnusForce(velocity_mps, spin_radps,
60 magnus_coefficient_);
61 }
62
63 private:
64 double magnus_coefficient_{1.0e-4};
65};
66
67} // namespace frcsim
double magnusCoefficient() const
Returns the current Magnus coefficient.
Definition magnus_model.hpp:35
void setMagnusCoefficient(double coefficient)
Updates the Magnus coefficient used by computeForce().
Definition magnus_model.hpp:41
Vector3 computeForce(const Vector3 &velocity_mps, const Vector3 &spin_radps) const
Computes the lift force produced by the supplied velocity and spin.
Definition magnus_model.hpp:57
MagnusModel(double magnus_coefficient=1.0e-4)
Creates a Magnus-force model with the given coefficient.
Definition magnus_model.hpp:31
Definition vector.hpp:13
3D vector utility used throughout JSim physics.
Definition vector.hpp:22
static Vector3 magnusForce(const Vector3 &velocity, const Vector3 &omega, double k=1e-4) noexcept
Computes the Magnus lift force omega x v scaled by k.
Definition vector.hpp:226