Hopsan
AuxiliarySimulationFunctions

Functions

double ifPositive (const double x, const double y1, const double y2)
 Returns y1 or y2 depending on the value of x.
 
bool doubleToBool (const double value)
 Converts a float point number to a boolean.
 
double boolToDouble (const bool value)
 Converts a boolean value to a float point number.
 
double onPositive (const double x)
 Returns 1.0 if x is positive, else returns 0.0.
 
double dxOnPositive (const double)
 
double onNegative (const double x)
 Returns 1.0 if x is negative, else returns 0.0.
 
double dxOnNegative (const double)
 
double dxAbs (const double x)
 
double d1Atan2L (const double y, const double x)
 
double d2Atan2L (const double y, const double x)
 Derivative of ATAN2L with respect to x.
 
double sign (const double x)
 Returns the sign of a double (-1.0 or +1.0)
 
double dtIfPositive (const double x, const double, const double)
 Derivative of IfPositive with respect to y1.
 
double dfIfPositive (const double x, const double, const double)
 Derivative of IfPositive with respect to y1.
 
double limit2 (const double x, const double, const double xmin, const double xmax)
 Overloads double hopsan::limit() to also include sx (derivative of x) as input.
 
double lowerLimit (const double value, const double limit)
 Apply a lower limit to a value.
 
double upperLimit (const double value, const double limit)
 Apply a upper limit to a value.
 
double deg2rad (const double deg)
 Converts an angle in degrees to radians.
 
double rad2deg (const double rad)
 Converts an angle in radians to degrees.
 
bool equalSignsBool (const double x, const double y)
 Check if input variables have the same sign.
 
double equalSigns (const double x, const double y)
 Check if input variables have the same sign.
 
void HOPSANCORE_DLLAPI limitValue (double &rValue, double min, double max)
 Limits a value so it is between min and max.
 
bool HOPSANCORE_DLLAPI fuzzyEqual (const double x, const double y, const double epsilon=0.00001)
 checks if two double variables are equal with a tolerance
 
double HOPSANCORE_DLLAPI signedSquareL (const double x, const double x0)
 
double HOPSANCORE_DLLAPI dxSignedSquareL (const double x, const double x0)
 
double HOPSANCORE_DLLAPI squareAbsL (const double x, const double x0)
 
double HOPSANCORE_DLLAPI dxSquareAbsL (const double x, const double x0)
 
double HOPSANCORE_DLLAPI Atan2L (const double y, const double x)
 Safe variant of atan2.
 
double HOPSANCORE_DLLAPI ArcSinL (const double x)
 Safe variant of asin.
 
double HOPSANCORE_DLLAPI dxArcSinL (const double x)
 derivative of AsinL
 
double HOPSANCORE_DLLAPI diffAngle (const double fi1, const double fi2)
 difference between two angles, fi1-fi2
 
double HOPSANCORE_DLLAPI CLift (const double alpha, const double CLalpha, const double ap, const double an, const double expclp, const double expcln)
 Lift coefficient for aircraft model.
 
double HOPSANCORE_DLLAPI CDragInd (const double alpha, const double AR, const double e, const double CLalpha, const double ap, const double an, const double expclp, const double expcln)
 Induced drag coefficient for aircraft model.
 
double HOPSANCORE_DLLAPI CMoment (double alpha, const double Cm0, const double Cmfs, const double ap, const double an, const double expclp, const double expcln)
 Moment coefficient for aircraft model.
 
double HOPSANCORE_DLLAPI segare (const double x, const double d)
 Segment area, used to calculate valve openings with circular holes.
 
double HOPSANCORE_DLLAPI dxSegare (const double x, const double d)
 Segment area, used to calculate valve openings with circular holes.
 
double HOPSANCORE_DLLAPI limit (const double x, const double xmin, const double xmax)
 Overloads void hopsan::limitValue() with a return value.
 
double HOPSANCORE_DLLAPI lowLimit (const double x, const double xmin)
 Limits a value to a lower limit.
 
double HOPSANCORE_DLLAPI dxLimit (const double x, const double xmin, const double xmax)
 Sets the derivative of x to zero if x is outside of limits.
 
double HOPSANCORE_DLLAPI dxLowLimit (const double x, const double xmin)
 Sets the derivative of x to zero if x is outside of limits.
 
double HOPSANCORE_DLLAPI dxLowLimit2 (const double x, const double sx, const double xmin)
 Sets the derivative of x to zero if x is outside of limits.
 
double HOPSANCORE_DLLAPI dxLimit2 (const double x, const double sx, const double xmin, const double xmax)
 Limits the derivative of x when x is outside of its limits.Returns 1.0 if x is within borders, or if x is outside borders but derivative has opposite sign (so that x can only move back to the limited range).
 

Variables

const double pi = 3.14159265358979323846
 A const double definition of pi that you can use in your code.
 

Detailed Description

Function Documentation

◆ boolToDouble()

double boolToDouble ( const bool value)
inline

Converts a boolean value to a float point number.

Parameters
valueBoolean to convert, will return 1.0 if true and 0.0 if false

◆ deg2rad()

double deg2rad ( const double deg)
inline

Converts an angle in degrees to radians.

Parameters
[in]degThe angle in degrees
Returns
The angle in radians

◆ dfIfPositive()

double dfIfPositive ( const double x,
const double ,
const double  )
inline

Derivative of IfPositive with respect to y1.

Parameters
[in]xinput value
Returns
Limited derivative of x

◆ doubleToBool()

bool doubleToBool ( const double value)
inline

Converts a float point number to a boolean.

Parameters
valueDouble value to convert, 1.0 means true, 0.0 means false

◆ dtIfPositive()

double dtIfPositive ( const double x,
const double ,
const double  )
inline

Derivative of IfPositive with respect to y1.

Parameters
[in]xinput value
Returns
Limited derivative of x

◆ dxLimit()

double dxLimit ( const double x,
const double xmin,
const double xmax )

Sets the derivative of x to zero if x is outside of limits.

Returns 1.0 if x is within limits, else 0.0. Used to make the derivative of x zero if limit is reached.

Parameters
xValue whose derivative is to be limited
xminMinimum value of x
xmaxMaximum value of x
Returns
Limited derivative of x

◆ dxLimit2()

double dxLimit2 ( const double x,
const double sx,
const double xmin,
const double xmax )

Limits the derivative of x when x is outside of its limits.Returns 1.0 if x is within borders, or if x is outside borders but derivative has opposite sign (so that x can only move back to the limited range).

Parameters
xValue whose derivative is to be limited
xminMinimum value of x
xmaxMaximum value of x
Returns
Limited derivative of x

◆ dxLowLimit()

double dxLowLimit ( const double x,
const double xmin )

Sets the derivative of x to zero if x is outside of limits.

Returns 1.0 if x is within limits, else 0.0. Used to make the derivative of x zero if limit is reached.

Parameters
xValue whose derivative is to be limited
xminMinimum value of x
Returns
Limited derivative of x

◆ dxLowLimit2()

double dxLowLimit2 ( const double x,
const double sx,
const double xmin )

Sets the derivative of x to zero if x is outside of limits.

Returns 1.0 if x is within limits, else 0.0. Used to make the derivative of x zero if limit is reached.

Parameters
xValue whose derivative is to be limited
xminMinimum value of x
Returns
Limited derivative of x

◆ dxSegare()

double dxSegare ( const double x,
const double d )

Segment area, used to calculate valve openings with circular holes.

Parameters
[in]xHow far into the circle
[in]dCircle diameter

◆ equalSigns()

double equalSigns ( const double x,
const double y )
inline

Check if input variables have the same sign.

Returns
1.0 (true) or 0.0 (false)

◆ equalSignsBool()

bool equalSignsBool ( const double x,
const double y )
inline

Check if input variables have the same sign.

Returns
true or false

◆ fuzzyEqual()

bool fuzzyEqual ( const double x,
const double y,
const double epsilon = 0.00001 )

checks if two double variables are equal with a tolerance

Parameters
[in]xFirst value
[in]ySecond value
[in]epsilonAllowed relative error
Note
Based on http://floating-point-gui.de/errors/comparison (20130429)

◆ ifPositive()

double ifPositive ( const double x,
const double y1,
const double y2 )
inline

Returns y1 or y2 depending on the value of x.

Parameters
xinput value
y1if x is positive
y2otherwise
Returns
Limited derivative of x

◆ limit()

double limit ( const double x,
const double xmin,
const double xmax )

Overloads void hopsan::limitValue() with a return value.

See also
void hopsan::limitValue(&value, min, max)
Parameters
xValue to be limited
xminMinimum value of x
xmaxMaximum value of x

◆ limit2()

double limit2 ( const double x,
const double ,
const double xmin,
const double xmax )
inline

Overloads double hopsan::limit() to also include sx (derivative of x) as input.

See also
void hopsan::limit(&x, min, max)
Parameters
xValue to be limited
sxDerivative of x
xminMinimum value of x
xmaxMaximum value of x
Returns
Limited x value

◆ limitValue()

void limitValue ( double & rValue,
double min,
double max )

Limits a value so it is between min and max.

Parameters
&rValueReference pointer to the value
minLower limit of the value
maxUpper limit of the value

◆ lowerLimit()

double lowerLimit ( const double value,
const double limit )
inline

Apply a lower limit to a value.

Parameters
[in]valueThe value to limit
[in]limitThe lower limit
Returns
limit if value < limit else value

◆ lowLimit()

double lowLimit ( const double x,
const double xmin )

Limits a value to a lower limit.

Parameters
xValue to be limited
xminMinimum value of x

◆ onNegative()

double onNegative ( const double x)
inline

Returns 1.0 if x is negative, else returns 0.0.

Parameters
xValue to determine if it is positive

◆ onPositive()

double onPositive ( const double x)
inline

Returns 1.0 if x is positive, else returns 0.0.

Parameters
xValue to determine if it is positive

◆ rad2deg()

double rad2deg ( const double rad)
inline

Converts an angle in radians to degrees.

Parameters
[in]radThe angle in radians
Returns
The angle in degrees

◆ segare()

double segare ( const double x,
const double d )

Segment area, used to calculate valve openings with circular holes.

Parameters
[in]xHow far into the circle
[in]dCircle diameter

◆ sign()

double sign ( const double x)
inline

Returns the sign of a double (-1.0 or +1.0)

Parameters
xValue to determine sign on

◆ upperLimit()

double upperLimit ( const double value,
const double limit )
inline

Apply a upper limit to a value.

Parameters
[in]valueThe value to limit
[in]limitThe upper limit
Returns
limit if value > limit else value