Marine systems simulation
CCrowfootMath Class Reference

#include <CCrowfootMath.h>

+ Collaboration diagram for CCrowfootMath:

Classes

struct  LineDef
 Defines a line connected between the collecting point of the crowfoot and a fastening position. More...
 
struct  VisualSpec
 

Public Member Functions

 CCrowfootMath (double maxLineForce=1.0e7, const VisualSpec &visualSpec=VisualSpec())
 The default constructor does nothing. More...
 
int AddLine (double length, const double *const fasteningpos)
 Adds a line to the collecting point. A line is added to the collecting point, the position of the other end of this line, as well as the length of the line may be moved between time steps. The returned integer is the index of the line, which is used for changing the other position and the length of the line later. More...
 
void Update (const double *const F, double *const posOut)
 Calculates the position of the collecting point and the forces in each attached line. The forces in each line are found using the GetLineForce() method or the GetLineTension() method. More...
 
void CalcIterativePos (const double *const F, double *const posOut, int maxNumIter=500, double expectedLengthToGo=3.0, double tolerance=0.00001)
 Calculates the position of the collecting point using an iterative method This method is for test purposes only. More...
 
void GetLineForce (double *F, int lineIndex)
 Gets the force on the fastening point for a given line. The line index should be that returned from the AddLine method. More...
 
double GetLineTension (int lineIndex)
 Gets the tension in the given line. The line index should be that returned from the AddLine method. More...
 
void UpdateLineLength (double length, int lineIndex)
 Updates the length of a given line. The line index should be that returned from the AddLine method. More...
 
void UpdateLineFasteningPos (const double *const fasteningpos, int lineIndex)
 Updates the "other" end position of a given line. The line index should be that returned from the AddLine method. More...
 
int NumLines ()
 Gets the number of lines attached to the collecting point.
 

Protected Member Functions

void CalcForOneLine (const Eigen::Vector3d &Force, const Eigen::Vector3d &ForceDir, double *const posOut)
 Calculates the collecting position and line force if the system is comprised of one line.
 
void CalcForTwoLines (const Eigen::Vector3d &Force, const Eigen::Vector3d &ForceDir, double *const posOut)
 Calculates the collecting position and line forces if the system is comprised of two lines.
 
void CalcForThreeLines (const Eigen::Vector3d &, const Eigen::Vector3d &ForceDir, double *const posOut)
 Calculates the collecting position and line forces if the system is comprised of three lines.
 
Eigen::Vector3d CalcPosForOneStretched (int index, const Eigen::Vector3d &ForceDir)
 Calculates the collecting position if only one line is stretched.
 
Eigen::Vector3d CalcPosForTwoStretched (int index1, int index2, const Eigen::Vector3d &ForceDir)
 Calculates the collecting position if only two lines are stretched.
 
void CalcForOneActive (int index, const Eigen::Vector3d &, const Eigen::Vector3d &pos, double *const posOut)
 Calculates the collecting position and line force if only one line is stretched.
 
void CalcForTwoActive (int index1, int index2, const Eigen::Vector3d &Force, Eigen::Vector3d pos, double *const posOut)
 Calculates the collecting position and line force if only two lines are stretched.
 
void SetPosition (double *const posOut, const Eigen::Vector3d &pos)
 Sets the position of the output array.
 
bool EnsureLineIndexOk (int lineIndex)
 Checks if a line index is ok. Prints a warning if not.
 
bool PointIsWithinLineReach (int index, const Eigen::Vector3d &connPos)
 Tests if a position is within the reach of a specified line.
 

Protected Attributes

std::vector< LineDefm_lines
 
std::vector< Eigen::Vector3d > m_lineForces
 
double m_maxLineForce
 
VisualSpec m_visualSpec
 

Detailed Description

Author
Karl-Johan Reite

Utility class for finding the position of the collecting point of a crowfoot and the forces on each connected line.

A run-time selected number of lines (1, 2 or 3) are attached to each other in a collection point. These lines are specified in terms of their length and fastening position. In addition, external forces acting on the collection point is specified. All positions and forces must be given in the same, not necessarily inertial, coordinate system.

This class finds the stable position of the collecting point, based on the forces acting on the point. This is done based on a direct solution, disregarding any dynamics. If one or two lines are stretched, the solution is found using geometric considerations. If three lines are active, the solution is found based on the method described in "Reliable computation of the points of intersection of n spheres in R^n" by I.D. Coope (Received 7 August 2000)

Revision history:
31.10.2013 KJR: Initial version.

Constructor & Destructor Documentation

◆ CCrowfootMath()

CCrowfootMath::CCrowfootMath ( double  maxLineForce = 1.0e7,
const VisualSpec visualSpec = VisualSpec() 
)

This constructor controls the visualization of the crow foot.

Member Function Documentation

◆ AddLine()

int CCrowfootMath::AddLine ( double  length,
const double *const  fasteningpos 
)
Parameters
[in]lengthThe length of the line.
[in]fasteningposThe posOut of the fastening point.
Returns
The index of the line, for later use by update functions.

◆ CalcIterativePos()

void CCrowfootMath::CalcIterativePos ( const double *const  F,
double *const  posOut,
int  maxNumIter = 500,
double  expectedLengthToGo = 3.0,
double  tolerance = 0.00001 
)
Parameters
[in]FThe sum of external forces.
[out]posOutThe calculated position of the collecting point.
[in]maxNumIterMax number of iterations
[in]expectedLengthToGoThe expected length to go
[in]toleranceTolerance for accepted convergence

◆ GetLineForce()

void CCrowfootMath::GetLineForce ( double *  F,
int  lineIndex 
)
Parameters
[in]FThe force on the fastening point.
[in]lineIndexThe index of the line.

◆ GetLineTension()

double CCrowfootMath::GetLineTension ( int  lineIndex)
Parameters
[in]lineIndexThe index of the line.

◆ Update()

void CCrowfootMath::Update ( const double *const  F,
double *const  posOut 
)
Parameters
[in]FThe sum of external forces.
[out]posOutThe calculated position of the collecting point.

◆ UpdateLineFasteningPos()

void CCrowfootMath::UpdateLineFasteningPos ( const double *const  fasteningpos,
int  lineIndex 
)
Parameters
[in]fasteningposThe position of the other end of the line.
[in]lineIndexThe index of the line.

◆ UpdateLineLength()

void CCrowfootMath::UpdateLineLength ( double  length,
int  lineIndex 
)
Parameters
[in]lengthThe relaxed length of the line.
[in]lineIndexThe index of the line.

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