//This file was generated by the LASAL2 CodeGenerator  -- 
//Please, do not edit this file (it might be overwritten by the next generator run)

//{{LSL_DEFINES
#define _INT_DEG                       * 1024 * 1000 //Internal Resolution of Degrees
#define LMC_PI                          3.1415926535897932384626433832795   //LMC_ avoids name clash

#define _LMC_EPSILON    0.000001
#define _MATH_EPSILON   0.000000001

//LREAL Zero Test:
#ifndef _LMCMATH_FLOAT_ISZERO
  #define _LMCMATH_FLOAT_ISZERO(p1)            ((p1 > -_LMC_EPSILON) & (p1 < _LMC_EPSILON))
#endif
#ifndef _LMCMATH_FLOAT_NOTZERO
  #define _LMCMATH_FLOAT_NOTZERO(p1)           ((p1 < -_LMC_EPSILON) | (p1 > _LMC_EPSILON))
#endif
#ifndef _LMCMATH_FLOAT_EQUAL
  #define _LMCMATH_FLOAT_EQUAL(p1,p2)          (((p1 - p2) < _LMC_EPSILON) & ((p1 - p2) > -_LMC_EPSILON))
#endif

#define _LMCMATH_LREAL_MAX  1.79E308
#define _LMCMATH_REAL_MAX   3.4E38

#ifndef _DINT_MIN
  #define _DINT_MIN -2147483648
#endif

#define LMC_NUMERIC_TOLERANCE   (0.000000001)
#define LMC_RESOLVE_TOLERANCE       (0.000000001)

// 25µsec für ein repeat auf ARM CP 111
#define LMC_MAX_REPEAT      25

// Geschwindigkeit wird auf 1 interne Einheit genau iteriert
#define PRECIS_REPEAT   (1.0)

//#define INTERN_MATH_TEST
//}}LSL_DEFINES

//{{LSL_DECLARATION
#include "..\..\Class\_LMCMathFunctions\C_MathFunct.h"

(*!
<Class
	Name               = "_LMCMathFunctions"
	Revision           = "1.75"
	GUID               = "{FF462027-C9E6-45E5-8FB9-2AEA1B69E953}"
	RealtimeTask       = "false"
	CyclicTask         = "false"
	BackgroundTask     = "false"
	Sigmatek           = "true"
	OSInterface        = "false"
	HighPriority       = "false"
	Automatic          = "false"
	UpdateMode         = "Prescan"
	IconPath           = ".\Class\_LMCMathFunctions\MATH2.ICO"
	SharedCommandTable = "true"
	Objectsize         = "(450,120)"
	Comment            = "The class _LMCMathFunctions makes important mathematical functions for the classes: &#13;&#10;_LMCAxisBase and _LMCProfileBase available. ">
	<Channels>
		<Server Name="ClassSvr" GUID="{99CC67E4-A745-4722-9555-DCA59E90D24D}" Visualized="false" Initialize="false" WriteProtected="true" Retentive="false"/>
	</Channels>
	<Dependencies>
		<Files>
			<File Path=".\Class\_LMCMathFunctions\C_MathFunct.h" Include="true"/>
			<File Path=".\Class\_LMCMathFunctions\C_MathFunct.cpp"/>
		</Files>
	</Dependencies>
	<RevDoku>
		<Owner Company="Sigmatek"/>
		<Dokumentation Revision="1.75" Date="2022-08-18" Author="SakEmi&#13;&#10;VelGer" Company="Sigmatek" Description="1. Bugfix: Macros LMCMATH_FLOAT_ISZERO, LMCMATH_FLOAT_NOTZERO and _LMCMATH_FLOAT_EQUAL are defined with common brackets.&#13;&#10;2. Improvement: Added new global methods Deg2Rad(), Rad2Deg() to scale radiants to degrees and vice versa in floating point. New global method RangeLimit() to limit LREAL values to defined limits."/>
		<Dokumentation Revision="1.74" Date="2022-03-10" Author="WalCla" Company="Sigmatek" Description="Renamed the local variable &quot;rad&quot; in the SolveCubic method to &quot;xrad&quot; to prevent collisions with potential unit defines."/>
		<Dokumentation Revision="1.73" Date="2022-02-07" Author="StePhi" Company="Sigmatek" Description="Improvement: Internal calculation of quadatric or cubic terms are now done by multiplication rather than using the power function."/>
		<Dokumentation Revision="1.72" Date="2021-09-22" Author="StePhi" Company="Sigmatek" Description="1. Improvement: Added a function to calculate the vector sum of two vectors. Added a function which returns the normated vector of a given vector."/>
		<Dokumentation Revision="1.71" Date="2020-01-04" Author="VelGer" Company="Sigmatek" Description="1. Improvement: New Functions for calculating a constant Jerk Move Profile added."/>
		<Dokumentation Revision="1.70" Date="2019-05-16" Author="SliMic&#13;&#10;VelGer" Company="Sigmatek" Description="1. Improvement: GetBendAngle() added&#13;&#10;2. Improvement: Added VectorMagnitude() to allow the calculation of a the magnitude of a vector with 3 components."/>
		<Dokumentation Revision="1.69" Date="2018-11-09" Author="PalHar" Company="Sigmatek" Description="1. Improvement: new methods maxi_DINT and maxi_LREAL&#13;&#10;2. Bugfix: Numerical stability of solveQuartic improved."/>
		<Dokumentation Revision="1.68" Date="2018-10-01" Author="PalHar" Company="Sigmatek" Description="Improvement: New methods: solveQuadratic, solveCubic, solveQuartic, bubbleSort_4, solveNewton_1"/>
		<Dokumentation Revision="1.67" Date="2017-09-28" Author="PalHar" Company="Sigmatek" Description="Improvement: GetBendRadius() added"/>
		<Dokumentation Revision="1.66" Date="2016-09-20" Author="SatChar" Company="Sigmatek" Description="bugfix in function MulDiv64_64 in appended C file C_MathFunct.cpp for _LMCAxis v1.70 and EDGE2 CPUs"/>
		<Dokumentation Revision="1.65" Date="2016-01-26" Author="SatChr" Company="Sigmatek" Description="changes in appended C file C_MathFunct.cpp for _LMCAxis v1.60"/>
		<Dokumentation Revision="1.64" Date="2015-12-04" Author="PALHAR&#13;&#10;SatChr" Company="Sigmatek" Description="1. Improvement: new methods added: VectorProduct,  ScalarProduct, TestVectorToZero, VectorNorm, and mini2_LREAL&#13;&#10;2. Improvement: Not needed methods SetParameter and truncLongRealToDint removed&#13;&#10;"/>
		<Dokumentation Revision="1.63" Date="2015-04-20" Author="PALHAR&#13;&#10;FucHer&#13;&#10;SatChr" Company="Sigmatek" Description="1. Improvement: function CorrRoundPosC added to appended  C-file.&#13;&#10;2. Bugfix:  methode cubic_root(): the input-parameter in the elsif-branch must be requestet, not the output-parameter"/>
		<Dokumentation Revision="1.62" Date="2014-12-15" Author="SatChr" Company="Sigmatek" Description="changes in appended C files"/>
		<Dokumentation Revision="1.61" Date="2014-11-24" Author="HasHan" Company="Sigmatek" Description="1. Improvement: cleanup of some old methodes"/>
		<Dokumentation Revision="1.60" Date="2014-01-27" Author="HasHan" Company="Sigmatek" Description="1. Improvement: changes because of ARM"/>
		<Dokumentation Revision="1.50" Date="2013-07-18" Author="FuchsH&#13;&#10;HasHan&#13;&#10;PalHar&#13;&#10;" Company="Sigmatek" Description="1. New file C_MathFunct.cpp contains the C versions of various mathematical functions. AWL methods removed.&#13;&#10;2. this class can now be used standalone, because there is a dummy-type to import all global-types needed by the c-functions&#13;&#10;3. Error in the function: CalcTangError: the transfer parameter: Angl (Winkel*100) is limited on 180° . This value is not passed on to the local variable and therefore calculated wrongly.&#13;&#10;4.  this class is now arm-compatible"/>
		<Dokumentation Revision="1.40" Date="2012-09-27" Author="PalHar&#13;&#10;HasHan" Company="Sigmatek" Description="1) issue 670: bug fixed: function: &quot;CalcTangError&quot; corrected&#13;&#10;2)  moved some functions to the _LMCProfileBase&#13;&#10;     add the function IntersectLinLin&#13;&#10;3) changes because of global types"/>
		<Dokumentation Revision="1.30" Date="2012-03-12" Author="FuchsH&#13;&#10;RauAnd&#13;&#10;walrob" Company="Sigmatek" Description="CalcAngleByPos(), AngleCalcNkPos(): _LMCMT_CirCW_Lin_Round_Aux new (rounding with tolerance sphere).&#13;&#10;Konstante PI definiert.&#13;&#10;MulDiv64Ext Umbau."/>
		<Dokumentation Revision="1.20" Date="2011-06-10" Author="walrob" Company="Sigmatek" Description="New Functions for _LMCProfile"/>
		<Dokumentation Revision="1.10&#13;&#10;" Date="2011-06-10" Author="FuchsH" Company="Sigmatek" Description="Class Creation"/>
	</RevDoku>
</Class>
*)
_LMCMathFunctions : CLASS
	TYPE
#pragma pack(push, 4)
	  _coeff_ : STRUCT  //! <Type Public="true" Name="_coeff_"/>
	    coA : LREAL;
	    coB : LREAL;
	    coC : LREAL;
	    coD : LREAL;
	    coE : LREAL;
	  END_STRUCT;
#pragma pack(pop)
	  _COORD_2D : ARRAY [0..1] OF DINT;  //! <Type Public="true" Comment="Coordinates of a point on a plain" Name="_COORD_2D"/>
#pragma pack(push, 4)
	  _LMC_VECTOR3 : STRUCT  //! <Type Public="true" Name="_LMC_VECTOR3"/>
	    coord_x1 : LREAL;
	    coord_x2 : LREAL;
	    coord_x3 : LREAL;
	  END_STRUCT;
#pragma pack(pop)
	  t_e_LMC_MoveProf_Jerk_ProfTypes :  //! <Type Public="true" Comment="This enumeration contains the possible types of Constant Jerk Profiles that can be represented in the _LMCMathFunctions::t_st_LMC_MoveProf_Jerk Structure.&#13;&#10;For a description of the meaning of each of the options of this enum, refer to the comments on the option itself.&#13;&#10;&#13;&#10;The W and T characters represent the form of the Acceleration and Deceleration sections of the movment profile respectively and carry the following meaning:&#13;&#10;T: Trapezium -&gt; Acceleration / Deceleration reaches its maximum and possibly maintains the maximum value for a time.&#13;&#10;W: Wedge -&gt;Acceleration / Deceleration does not necessarily reach its maximum value, however it could do so.&#13;&#10;X: None -&gt; Relative Acceleration / Deceleration section is not present." Name="t_e_LMC_MoveProf_Jerk_ProfTypes"/>
	  (
	    LMC_ProfType_Jerk_TT,  //! <Type Comment="This value indicates a Trapezium - Trapezium profile, a profile of this sort has an acceleration section that is formed like a trapezium (reaches maximum acceleration) and a deceleration section that is formed like a trapezium (reaches maximum deceleration)." Name="t_e_LMC_MoveProf_Jerk_ProfTypes.LMC_ProfType_Jerk_TT"/>
	    LMC_ProfType_Jerk_TW,  //! <Type Comment="This value indicates a Trapezium - Wedge profile, a profile of this sort has an Acceleration section that is formed like a Trapezium (reaches maximum acceleration) and a deceleration section that is formed like a Wedge (does not necessarily reach maximum deceleration)." Name="t_e_LMC_MoveProf_Jerk_ProfTypes.LMC_ProfType_Jerk_TW"/>
	    LMC_ProfType_Jerk_WW,  //! <Type Comment="This value indicates a Wedge - Wedge profile, a profile of this sort has an Acceleration section that is formed like a Wedge (does not necessarily reach maximum acceleration) and a deceleration section that is formed like a Wedge (does not necessarily reach maximum deceleration)." Name="t_e_LMC_MoveProf_Jerk_ProfTypes.LMC_ProfType_Jerk_WW"/>
	    LMC_ProfType_Jerk_WT,  //! <Type Comment="This value indicates a Trapezium - Wedge profile, a profile of this sort has an Acceleration section that is formed like a Trapezium (reaches maximum acceleration) and a deceleration section that is formed like a Wedge (does not necesarilly reach maximum deceleration)." Name="t_e_LMC_MoveProf_Jerk_ProfTypes.LMC_ProfType_Jerk_WT"/>
	    LMC_ProfType_Jerk_XW,  //! <Type Comment="This value indicates an X - Wedge profile, a profile of this sort has no Acceleration section and a Deceleration section that is formed like a Wedge (does not necessarily reach maximum deceleration)." Name="t_e_LMC_MoveProf_Jerk_ProfTypes.LMC_ProfType_Jerk_XW"/>
	    LMC_ProfType_Jerk_XT  //! <Type Comment="This value indicates an X - Trapezium profile, a profile of this sort has no Acceleration section and a Deceleration section that is formed like a Trapezium (does reach maximum deceleration)." Name="t_e_LMC_MoveProf_Jerk_ProfTypes.LMC_ProfType_Jerk_XT"/>
	  )$UDINT;
	  t_e_LMCMath_Retcodes :  //! <Type Public="true" Comment="This Enumeration contains return values &amp; error codes for the functions in the _LMCMathFunctions class. For an explanation of each entry, refer to the comments of the entry." Name="t_e_LMCMath_Retcodes"/>
	  (
	    LMCMathRet_NoError,  //! <Type Comment="This Returncode indicates that the operation completed successfully." Name="t_e_LMCMath_Retcodes.LMCMathRet_NoError"/>
	    LMCMathRet_NegRoot,  //! <Type Comment="This Returncode indicates that the function has attempted to calculate a negative Root value internally and was stopped as to not deliver an incorrect result, depending on the method called, this could be due to incorrect input values." Name="t_e_LMCMath_Retcodes.LMCMathRet_NegRoot"/>
	    LMCMathRet_InputErr,  //! <Type Comment="This Returncode indicates that the input supplied to the function was either out of range or invlaid, check:&#13;&#10;1. All required pointers are set.&#13;&#10;2. The values passed as parameters are within bounds.&#13;&#10;&#13;&#10;To establish the valid range and allowable inout values for each parameter, look at the comment of the input parameter in the function as well as the documentation of the class." Name="t_e_LMCMath_Retcodes.LMCMathRet_InputErr"/>
	    LMCMathRet_NotPossible  //! <Type Comment="This Returncode indicates that the calculation is not possible to perform, it could indicate that the values passed to the input parameters of the function represent an impossible movement, etc.&#13;&#10;For help on the specific cause for this return value, refer to the comments of the output parameter of the function." Name="t_e_LMCMath_Retcodes.LMCMathRet_NotPossible"/>
	  )$UDINT;
#pragma pack(push, 1)
	  t_st_LMC_MoveProf_Jerk_Point : STRUCT  //! <Type Public="true" Comment="This structure is used in the _LMCMathFunctions::t_st_MoveProf_Jerk structure, for a description of the meaning of the points along the profile, refer to the comments of the aforementioned structure." Name="t_st_LMC_MoveProf_Jerk_Point"/>
	    lrT : LREAL;  //! <Type Comment="This element indicates the absolute point in time of the point along the profile." Name="t_st_LMC_MoveProf_Jerk_Point.lrT"/>
	    lrS : LREAL;  //! <Type Comment="This element indicates the position of the profile in the point." Name="t_st_LMC_MoveProf_Jerk_Point.lrS"/>
	    lrV : LREAL;  //! <Type Comment="This element indicates the Velocity of the profile in the point." Name="t_st_LMC_MoveProf_Jerk_Point.lrV"/>
	    lrA : LREAL;  //! <Type Comment="This element indicates the Acceleration of the profile in the point." Name="t_st_LMC_MoveProf_Jerk_Point.lrA"/>
	    lrJ : LREAL;  //! <Type Comment="This element indicates the Jerk of the profile in the point." Name="t_st_LMC_MoveProf_Jerk_Point.lrJ"/>
	  END_STRUCT;
#pragma pack(pop)
#pragma pack(push, 1)
	  t_st_LMC_MoveProf_Jerk : STRUCT  //! <Type Public="true" Comment="This structure represents a Constant Jerk movement Profile, the relative functions to manipulate the structure are found in the _LMCMathFunctions class:&#13;&#10;_LMCMathFunctions::CalcMoveProf_Jerk()&#13;&#10;_LMCMathFunctions::CalcMoveProfDist_Jerk(), etc.&#13;&#10;&#13;&#10;To create a movement profie, allocate memory for a structure of this type, and manipulate the memory using the aforementioned functions.&#13;&#10;&#13;&#10;Description of the sections of the movement profile:&#13;&#10;Points 0 -&gt; 1 - This section of the profile is only used if the movement is started with a negative acceleration.&#13;&#10;Points 1 -&gt; 2 - This is the first part of the acceleration section, in this section Jerk is positive (lrJ &gt; 0).&#13;&#10;Points 2 -&gt; 3 - This is the second part of the acceleration section and represents the constant part of the section, therefor, it only has a duration greater than 0 if the profile is of the form TT / TW / TX. Furthermore, this section always has a Jerk value of 0 (lrJ = 0).&#13;&#10;Points 3 -&gt; 4 - This is the last part of the acceleration section, in this section Jerk is negative (lrJ &lt; 0).&#13;&#10;Points 4 -&gt; 5 - This represents the cruise section of the movement profile, during this section the velocity is contant, therefore both Acceleration and Jerk are 0 (lrA = 0 &amp; lrJ = 0).&#13;&#10;Points 5 -&gt; 6 - This is the first part of the deceleration section in this section Jerk is negative.&#13;&#10;Points 6 -&gt; 7 - This is the second part of the deceleration section and represents the constant part of the section, therefor, it only has a duration greater than 0 if the profile is of the form TT / WT / XT. Furthermore, this section always has a Jerk value of 0 (lrJ = 0).&#13;&#10;Points 7 -&gt; 8 - This is the last part of the deceleration section (ramps acceleration back up to the final value / 0), in this section Jerk is positive.&#13;&#10;Points 8 -&gt; 9 - This is the last part of the movement profile and is only used if the profile has a final acceleration greater than 0, in all other cases the duration of this section is zero." Name="t_st_LMC_MoveProf_Jerk"/>
	    ProfileType : t_e_LMC_MoveProf_Jerk_ProfTypes;  //! <Type Comment="This element indicates the type of the profile represented, for a discussion of each possible type refer to the comments on the _LMCMathFunctions::t_e_LMC_MoveProf_Jerk_ProfTypes definition." Name="t_st_LMC_MoveProf_Jerk.ProfileType"/>
	    aPts : ARRAY [0..9] OF t_st_LMC_MoveProf_Jerk_Point;  //! <Type Comment="This element contains an array of the points along the constant jerk profile.&#13;&#10;&#13;&#10;Description of the sections of the movement profile:&#13;&#10;Points 0 -&gt; 1 - This section of the profile is only used if the movement is started with a negative acceleration.&#13;&#10;Points 1 -&gt; 2 - This is the first part of the acceleration section, in this section Jerk is positive (lrJ &gt; 0).&#13;&#10;Points 2 -&gt; 3 - This is the second part of the acceleration section and represents the constant part of the section, therefor, it only has a duration greater than 0 if the profile is of the form TT / TW / TX. Furthermore, this section always has a Jerk value of 0 (lrJ = 0).&#13;&#10;Points 3 -&gt; 4 - This is the last part of the acceleration section, in this section Jerk is negative (lrJ &lt; 0).&#13;&#10;Points 4 -&gt; 5 - This represents the cruise section of the movement profile, during this section the velocity is contant, therefore both Acceleration and Jerk are 0 (lrA = 0 &amp; lrJ = 0).&#13;&#10;Points 5 -&gt; 6 - This is the first part of the deceleration section in this section Jerk is negative.&#13;&#10;Points 6 -&gt; 7 - This is the second part of the deceleration section and represents the constant part of the section, therefor, it only has a duration greater than 0 if the profile is of the form TT / WT / XT. Furthermore, this section always has a Jerk value of 0 (lrJ = 0).&#13;&#10;Points 7 -&gt; 8 - This is the last part of the deceleration section (ramps acceleration back up to the final value / 0), in this section Jerk is positive.&#13;&#10;Points 8 -&gt; 9 - This is the last part of the movement profile and is only used if the profile has a final acceleration greater than 0, in all other cases the duration of this section is zero." Name="t_st_LMC_MoveProf_Jerk.aPts"/>
	  END_STRUCT;
#pragma pack(pop)
	END_TYPE
  //Servers:
	ClassSvr 	: SvrChCmd_DINT;
  //Clients:
  //Variables:
		udIterations 	: UDINT;
  //Functions:
				//! <Function Comment="Returns the angle in the range from -90..0..+90 degrees [0.001 degrees * 1024]" Name="ArcSin"/>
	FUNCTION GLOBAL ArcSin
		VAR_INPUT
			dy 	: DINT;
			radius 	: DINT;
		END_VAR
		VAR_OUTPUT
			angle 	: DINT;
		END_VAR;
	
	FUNCTION GLOBAL bubbleSort_4
		VAR_INPUT
			x1 	: ^LREAL;
			x2 	: ^LREAL;
			x3 	: ^LREAL;
			x4 	: ^LREAL;
		END_VAR;
	
	FUNCTION GLOBAL CalcTangError
		VAR_INPUT
			Angle 	: DINT;			//! <Variable Comment="Angle in 1/1000°" Name="CalcTangError.Angle"/>
		END_VAR
		VAR_OUTPUT
			TangError 	: DINT;			//! <Variable Comment="Internal Angle Value" Name="CalcTangError.TangError"/>
		END_VAR;
	
	FUNCTION GLOBAL CalcTangErrorLREAL
		VAR_INPUT
			TangError 	: DINT;
		END_VAR
		VAR_OUTPUT
			RetValue 	: LREAL;
		END_VAR;
	
	FUNCTION GLOBAL cubic_root
		VAR_INPUT
			radic 	: LREAL;
		END_VAR
		VAR_OUTPUT
			croot 	: LREAL;
		END_VAR;
	
	FUNCTION GLOBAL getBendAngle
		VAR_INPUT
			pVecPQ 	: ^_LMC_VECTOR3;
			pVecPR 	: ^_LMC_VECTOR3;
			pVecQR 	: ^_LMC_VECTOR3;
			pAngle 	: ^LREAL;
			firstArc 	: BOOL;
		END_VAR
		VAR_OUTPUT
			MathOK 	: BOOL;
		END_VAR;
	
	FUNCTION GLOBAL getBendRadius
		VAR_INPUT
			pVecPQ 	: ^_LMC_VECTOR3;
			pVecPR 	: ^_LMC_VECTOR3;
			pVecQR 	: ^_LMC_VECTOR3;
			pRadius 	: ^LREAL;
			firstArc 	: BOOL;
		END_VAR
		VAR_OUTPUT
			MathOK 	: BOOL;
		END_VAR;
	
	FUNCTION GLOBAL IntersectLinLin
		VAR_INPUT
			Start1 	: _COORD_2D;
			Orient1 	: _COORD_2D;
			Start2 	: _COORD_2D;
			Orient2 	: _COORD_2D;
			pRetCode 	: ^iprStates;
		END_VAR
		VAR_OUTPUT
			Intersection 	: _COORD_2D;
		END_VAR;
				//! <Function Comment="This method normalizes the given vector and returns the result.&#13;&#10;When the given vector is a zero vector the original vector is returned." Name="NormalizeVector"/>
	FUNCTION GLOBAL NormalizeVector
		VAR_INPUT
			vec 	: _LMC_VECTOR3;			//! <Variable Comment="The original vector in the original length." Name="NormalizeVector.vec"/>
		END_VAR
		VAR_OUTPUT
			normalizedVec 	: _LMC_VECTOR3;			//! <Variable Comment="The normalized vecttor, when the given vector has a valid length. If not the original vector is returned." Name="NormalizeVector.normalizedVec"/>
		END_VAR;
	
	FUNCTION GLOBAL maxi2_DINT
		VAR_INPUT
			var1 	: DINT;
			var2 	: DINT;
		END_VAR
		VAR_OUTPUT
			ret_val 	: DINT;
		END_VAR;
	
	FUNCTION GLOBAL maxi2_LREAL
		VAR_INPUT
			var1 	: LREAL;
			var2 	: LREAL;
		END_VAR
		VAR_OUTPUT
			ret_val 	: LREAL;
		END_VAR;
	
	FUNCTION GLOBAL mini2_DINT
		VAR_INPUT
			var1 	: DINT;
			var2 	: DINT;
		END_VAR
		VAR_OUTPUT
			ret_val 	: DINT;
		END_VAR;
	
	FUNCTION GLOBAL mini2_LREAL
		VAR_INPUT
			var1 	: LREAL;
			var2 	: LREAL;
		END_VAR
		VAR_OUTPUT
			ret_val 	: LREAL;
		END_VAR;
				//! <Function Comment="This method is used to calculate the total distance travelled by a constant jerk profile. To use the method the structure pointer passed to the pMoveProfile input parameter must have been calculated by the _LMCMathFunctions::CalcMoveProf_Jerk() method." Name="MoveProfJerk_ProfileDist"/>
	FUNCTION MoveProfJerk_ProfileDist
		VAR_INPUT
			pMoveProfile 	: ^_LMCMathFunctions::t_st_LMC_MoveProf_Jerk;			//! <Variable Comment="Pointer to the move profile stucture of which the travel distance is to be calculated.&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pMoveProfile &lt;&gt; NIL." Name="MoveProfJerk_ProfileDist.pMoveProfile"/>
			pMoveDist 	: ^LREAL;			//! <Variable Comment="Pointer to the variable on which the calculated move distance must be written.&#13;&#10;&#13;&#10;Possible values are:&#13;&#10;pMoveDist &lt;&gt; NIL" Name="MoveProfJerk_ProfileDist.pMoveDist"/>
		END_VAR
		VAR_OUTPUT
			Retcode 	: _LMCMathFunctions::t_e_LMCMath_Retcodes;			//! <Variable Comment="The Return code indicates whether the calculation was successful.&#13;&#10;&#13;&#10;Possible values are:&#13;&#10;LMCMathRet_NoError -&gt; The calculation completed successfully.&#13;&#10;LMCMathRet_InputErr -&gt; Either pMoveProfile or pMoveDist is set to NIL, ensure that the input parameters are valid." Name="MoveProfJerk_ProfileDist.Retcode"/>
		END_VAR;
				//! <Function Comment="This method is used to calculate a constant jerk movement profile for the starting, ending and limit values supplied.&#13;&#10;&#13;&#10;To use this method:&#13;&#10;1. Allocate memory for a structure of the type _LMCMathFunctions::t_st_LMC_MoveProf_Jerk.&#13;&#10;2. Call the function passing the relative values to the input parameters, a constant jerk profile is then calculated and written to the memory.&#13;&#10;&#13;&#10;For a discussion on the input values, refer to the comments for each.&#13;&#10;For a list of possible return values and the meaning of each, refer to the comments of the return parameter (Retcode)." Name="MoveProfJerk_CalcProfile_Full"/>
	FUNCTION GLOBAL MoveProfJerk_CalcProfile_Full
		VAR_INPUT
			pDist 	: ^LREAL;			//! <Variable Comment="This parameter receives a pointer to a LREAL value containing the distance that the movement should travel. &#13;&#10;The distance should be a non-zero value (pDist^ &gt; 0).&#13;&#10;&#13;&#10;When using SI units, this value has a unit of Meters (m).&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pDist &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pDist"/>
			pVs 	: ^LREAL;			//! <Variable Comment="This parameter receives a pointer to a LREAL value containing the initial velocity that the movement should have. &#13;&#10;The velocity value should be smaller than the maximum velocity value passed to pVmax: (-pVMax^ &lt;= pVs^ &lt;= pVMax^).&#13;&#10;&#13;&#10;When using SI units, this value has a unit of Meters per Second (m*s^-1).&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pVs &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pVs"/>
			pVe 	: ^LREAL;			//! <Variable Comment="This parameter receives a pointer to a LREAL value containing the final velocity that the movement should have. &#13;&#10;The velocity value should be smaller than the maximum velocity value passed to pVmax: (-pVMax^ &lt;= pVe^ &lt;= pVMax^).&#13;&#10;&#13;&#10;When using SI units, this value has a unit of Meters per Second (m*s^-1).&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pVe &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pVe"/>
			pAs 	: ^LREAL;			//! <Variable Comment="This parameter receives a pointer to a LREAL value containing the initial acceleration that the movement should have. &#13;&#10;The acceleration value should be smaller than the maximum acceleration value passed to pAmax: (-pAMax^ &lt;= pAs^ &lt;= pAMax^).&#13;&#10;&#13;&#10;When using SI units, this value has a unit of Meters per Second^2 (m*s^-2).&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pAs &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pAs"/>
			pAe 	: ^LREAL;			//! <Variable Comment="This parameter receives a pointer to a LREAL value containing the final acceleration that the movement should have. &#13;&#10;The acceleration value should be smaller than the maximum acceleration value passed to pAmax: (-pAMax^ &lt;= pAe^ &lt;= pAMax^).&#13;&#10;&#13;&#10;When using SI units, this value has a unit of Meters per Second^2 (m*s^-2).&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pAe &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pAe"/>
			pVmax 	: ^LREAL;			//! <Variable Comment="This parameter receives a pointer to a LREAL value containing the maximum allowable velocity for the movment to be calculated.&#13;&#10;The velocity value should be a positive value, greater than 0: (pVMax^ &gt; 0).&#13;&#10;&#13;&#10;When using SI units, the value has the unit of Meters per Second (m*s^-1).&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pVMax &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pVmax"/>
			pAmax 	: ^LREAL;			//! <Variable Comment="This parameter receives a pointer to a LREAL value containing the maximum allowable acceleration for the movment to be calculated.&#13;&#10;The acceleration value should be a positive value, greater than 0: (pAMax^ &gt; 0).&#13;&#10;&#13;&#10;When using SI units, the value has the unit of Meters per Second^2 (m*s^-2).&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pAMax &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pAmax"/>
			pJerk 	: ^LREAL;
			pMoveProfile 	: ^_LMCMathFunctions::t_st_LMC_MoveProf_Jerk;			//! <Variable Comment="Pointer to the movment structure in memory where the result of the movment calculation should be stored.&#13;&#10;&#13;&#10;Possible Values are:&#13;&#10;pMoveProfile &lt;&gt; NIL." Name="MoveProfJerk_CalcProfile_Full.pMoveProfile"/>
		END_VAR
		VAR_OUTPUT
			Retcode 	: _LMCMathFunctions::t_e_LMCMath_Retcodes;			//! <Variable Comment="The return value indicates the status of the movement profile calculation, normally LMCMath_NoError should be returned to idicate success.&#13;&#10;&#13;&#10;The following return values are possible:&#13;&#10;LMCMathRet_NoError -&gt; The calculation completed successfully, values in the pMoveProfile^ structure are usable.&#13;&#10;LMCMathRet_NegRoot -&gt; The calculation failed because a negative root was calculated internally, the values in the pMoveProfile^ structure are not usable. This could be caused by:&#13;&#10;1. A too large initial velocity being passed to the method (abs(pVs^) &gt; abs(pVmax^))&#13;&#10;1. A too large final velocity being passed to the method (abs(pVe^) &gt; abs(pVmax^))&#13;&#10;LMCMathRet_InputErr -&gt; One of the input values contain a NIL pointer or a value that is out of range, see the comments of each of the input parameters for the valid range of each." Name="MoveProfJerk_CalcProfile_Full.Retcode"/>
		END_VAR;
				//! <Function Comment="This method is used to calculate the zero cruise profile for the input parameters supplied.&#13;&#10;It is possible to return only the profile or distance travelled by setting the pointer to the item not required to NIL.&#13;&#10;&#13;&#10;The Zero Cruise profile is the movement profile that ramps the Starting Velocity and Acceleration to the specified End values using the Constant Jerk specified whilst not exceeding the Acceleration and Veloctiy limits specified.&#13;&#10;For the build of the Constant Jerk Movement profile, see the _LMCMathFunctions Help.&#13;&#10;&#13;&#10;For a discussion on each of the Input and Return values, refer to the comment section of each." Name="MoveProfJerk_CalcProfile_ZeroCruise"/>
	FUNCTION GLOBAL MoveProfJerk_CalcProfile_ZeroCruise
		VAR_INPUT
			pDist 	: ^LREAL;
			pVs 	: ^LREAL;
			pVe 	: ^LREAL;
			pAs 	: ^LREAL;
			pAe 	: ^LREAL;
			pVmax 	: ^LREAL;
			pAmax 	: ^LREAL;
			pJerk 	: ^LREAL;
			pMoveProfile 	: ^_LMCMathFunctions::t_st_LMC_MoveProf_Jerk;
		END_VAR
		VAR_OUTPUT
			Retcode 	: _LMCMathFunctions::t_e_LMCMath_Retcodes;
		END_VAR;
	
	FUNCTION GLOBAL MoveJerkProf_CalcProfile_Stop
		VAR_INPUT
			pVs 	: ^LREAL;
			pAs 	: ^LREAL;
			pAmax 	: ^LREAL;
			pJerk 	: ^LREAL;
			pMoveProfile 	: ^_LMCMathFunctions::t_st_LMC_MoveProf_Jerk;
		END_VAR
		VAR_OUTPUT
			Retcode 	: _LMCMathFunctions::t_e_LMCMath_Retcodes;
		END_VAR;
				//! <Function Comment="This method calculates the achievable velocity and time required to achieve the velocity over a defined distance for a constant Jerk movement with Acceleration Limiting.&#13;&#10;&#13;&#10;The following assumptions are made:&#13;&#10;1. Starting Velocity = 0&#13;&#10;2. Starting and Ending Accel = 0&#13;&#10;&#13;&#10;For a description of each of the input and output variables, refer to the comments of each." Name="MoveJerk_AchievableVelTime"/>
	FUNCTION GLOBAL MoveJerk_AchievableVelTime
		VAR_INPUT
			pDist 	: ^LREAL;			//! <Variable Comment="This Parameter should point to the variable containing the Distance to be travelled.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pDist &lt;&gt; NIL." Name="MoveJerk_AchievableVelTime.pDist"/>
			pJMove 	: ^LREAL;			//! <Variable Comment="This Parameter should point to the variable containing the Constant Jerk to be used during the move.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pJMove &lt;&gt; NIL." Name="MoveJerk_AchievableVelTime.pJMove"/>
			pAMax 	: ^LREAL;			//! <Variable Comment="This Parameter should point to the variable containing the Acelleration Limit to be considered during the move.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pAMax &lt;&gt; NIL." Name="MoveJerk_AchievableVelTime.pAMax"/>
			pVe 	: ^LREAL;			//! <Variable Comment="This Parameter can point to the variable where the Ending velocity is to be written.&#13;&#10;The parameter can be set to NIL if the final velocity is not required.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pVe = NIL -&gt; The Final Velocity is not delivered.&#13;&#10;pVe &lt;&gt; NIL -&gt; The Final Velocity is written to the variable pointed to." Name="MoveJerk_AchievableVelTime.pVe"/>
			pDuration 	: ^LREAL;			//! <Variable Comment="This Parameter can point to the variable where the total move duration is to be written.&#13;&#10;The parameter can be set to NIL if the move duration is not required.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pDuration = NIL -&gt; The Move Duration is not delivered.&#13;&#10;pDuration &lt;&gt; NIL -&gt; The Move Duration is written to the variable pointed to." Name="MoveJerk_AchievableVelTime.pDuration"/>
		END_VAR
		VAR_OUTPUT
			RetCode 	: t_e_LMCMath_Retcodes;			//! <Variable Comment="The return code indicates the success of the method execution.&#13;&#10;&#13;&#10;The following values can be returned:&#13;&#10;LMCMathRet_NoError -&gt; The method executed successfully, the delivered values can be used.&#13;&#10;LMCMathRet_InputErr -&gt; The method failed to execute as input information was not sufficient, possible causes are:&#13;&#10;1. pDist = NIL.&#13;&#10;2. pJMove = NIL.&#13;&#10;3. pAMax = NIL.&#13;&#10;4. pVe = NIL &amp; pDuration = NIL. -&gt; Atleast one of these two pointers must be set." Name="MoveJerk_AchievableVelTime.RetCode"/>
		END_VAR;
				//! <Function Comment="This method calculates the scalar product of two 3-dimensional vectors." Name="ScalarProduct"/>
	FUNCTION GLOBAL ScalarProduct
		VAR_INPUT
			pvec_A 	: ^_LMC_VECTOR3;
			pvec_B 	: ^_LMC_VECTOR3;
		END_VAR
		VAR_OUTPUT
			scal_AB 	: LREAL;
		END_VAR;
				//! <Function Comment="This function returns the smallest positive value out of the 3 input values.&#13;&#10;All input values are required, atleast one must be positive for the function to work.&#13;&#10;&#13;&#10;For possible in- and output parameters, see the comment section of each." Name="SmallestPosOf3"/>
	FUNCTION GLOBAL SmallestPosOf3
		VAR_INPUT
			pVal1 	: ^LREAL;			//! <Variable Comment="Pointer to the first LREAL value for comparison.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pVal1 &lt;&gt; NIL." Name="SmallestPosOf3.pVal1"/>
			pVal2 	: ^LREAL;			//! <Variable Comment="Pointer to the second LREAL value for comparison.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pVal2 &lt;&gt; NIL." Name="SmallestPosOf3.pVal2"/>
			pVal3 	: ^LREAL;			//! <Variable Comment="Pointer to the third LREAL value for comparison.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pVal3 &lt;&gt; NIL." Name="SmallestPosOf3.pVal3"/>
		END_VAR
		VAR_OUTPUT
			pSmallestPos 	: ^LREAL;			//! <Variable Comment="Pointer to the LREAL value with the smallest positive value.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pSmallestPos &lt;&gt; NIL -&gt; The return value points to the smallest positive value.&#13;&#10;pSmallestPos = NIL -&gt; 1. Not all input values are set, check input parameters, or 2. No positive values are present." Name="SmallestPosOf3.pSmallestPos"/>
		END_VAR;
	
	FUNCTION GLOBAL solveCubic
		VAR_INPUT
			x1 	: ^LREAL;
			x2 	: ^LREAL;
			x3 	: ^LREAL;
			Coeff 	: _coeff_;
		END_VAR
		VAR_OUTPUT
			Success 	: DINT;
		END_VAR;
	
	FUNCTION GLOBAL solveNewton_1
		VAR_INPUT
			Vi 	: LREAL;
			Vo 	: LREAL;
			Vm 	: LREAL;
			Sj 	: LREAL;
		END_VAR
		VAR_OUTPUT
			VC 	: LREAL;
		END_VAR;
	
	FUNCTION GLOBAL solveQuadratic
		VAR_INPUT
			x1 	: ^LREAL;
			x2 	: ^LREAL;
			Coeff 	: _coeff_;
		END_VAR
		VAR_OUTPUT
			Success 	: DINT;
		END_VAR;
	
	FUNCTION GLOBAL soveQuartic
		VAR_INPUT
			x1 	: ^LREAL;
			x2 	: ^LREAL;
			x3 	: ^LREAL;
			x4 	: ^LREAL;
			Coeff 	: _coeff_;
		END_VAR
		VAR_OUTPUT
			Success 	: DINT;
		END_VAR;
	
	FUNCTION GLOBAL TestVectorToZero
		VAR_INPUT
			pvec_0 	: ^_LMC_VECTOR3;
		END_VAR
		VAR_OUTPUT
			isZero 	: BOOL;
		END_VAR;
				//! <Function Comment="This method delivers the magnitude of a vector with 3 components" Name="VectorMagnitude"/>
	FUNCTION GLOBAL VectorMagnitude
		VAR_INPUT
			pvec_A 	: ^_LMC_VECTOR3;			//! <Variable Comment="Pointer to the vector to be analyzed." Name="VectorMagnitude.pvec_A"/>
		END_VAR
		VAR_OUTPUT
			mag_A 	: LREAL;			//! <Variable Comment="Magnitude (Length) of the vector." Name="VectorMagnitude.mag_A"/>
		END_VAR;
	
	FUNCTION GLOBAL VectorNorm
		VAR_INPUT
			pvec_A 	: ^_LMC_VECTOR3;
		END_VAR
		VAR_OUTPUT
			norm_A 	: LREAL;
		END_VAR;
	
	FUNCTION GLOBAL VectorProduct
		VAR_INPUT
			pvec_A 	: ^_LMC_VECTOR3;
			pvec_B 	: ^_LMC_VECTOR3;
		END_VAR
		VAR_OUTPUT
			vec_AxB 	: _LMC_VECTOR3;
		END_VAR;
				//! <Function Comment="Adds a vector an existing vector." Name="VectorAdd"/>
	FUNCTION GLOBAL VectorAdd
		VAR_INPUT
			pVec 	: ^_LMC_VECTOR3;			//! <Variable Comment="Original vector containing the result of the addition." Name="VectorAdd.pVec"/>
			pVecAdd 	: ^_LMC_VECTOR3;			//! <Variable Comment="Vector which is added to pVec." Name="VectorAdd.pVecAdd"/>
		END_VAR;
				//! <Function Comment="This function is used internally by the CalcMoveProf_Jerk() method, the method cuts a constant Jerk movement profile so that the distance travelled by it is shorter.&#13;&#10;&#13;&#10;Possible cutting sequences:&#13;&#10;TT -&gt; TW / WT / WW&#13;&#10;WT -&gt; WT / WW&#13;&#10;TW -&gt; TW / WW&#13;&#10;WW -&gt; WW&#13;&#10;&#13;&#10;For further discussion of the functionlity of this function refer to internal documentation." Name="MoveProfJerk_CutProfile"/>
	FUNCTION MoveProfJerk_CutProfile
		VAR_INPUT
			pMoveProf 	: ^t_st_LMC_MoveProf_Jerk;			//! <Variable Comment="Pointer to the movement profile to be cut.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pMoveProf &lt;&gt; NIL" Name="MoveProfJerk_CutProfile.pMoveProf"/>
			pReduceBy 	: ^LREAL := NIL;
			pLastReduction 	: ^LREAL := NIL;
		END_VAR
		VAR_OUTPUT
			RetCode 	: t_e_LMCMath_Retcodes;			//! <Variable Comment="Return code of this function is passed straight through to the _LMCMathFunctions::CalcMoveProf_Jerk() function and the meaning of each possible value is discussed in the comments of that function." Name="MoveProfJerk_CutProfile.RetCode"/>
		END_VAR;
				//! <Function Comment="This function is used internally by the CalcMoveProf_Jerk() method, the method cuts the velocity of the Acceleration / Deceleration Sections of a constant Jerk movement profile so that the distance travelled by it is shorter." Name="MoveProfJerk_CutProfile_ReduceAccDec"/>
	FUNCTION MoveProfJerk_CutProfile_ReduceAccDec
		VAR_INPUT
			pMoveProf 	: ^t_st_LMC_MoveProf_Jerk;			//! <Variable Comment="Pointer to the movement profile to be cut.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pMoveProf &lt;&gt; NIL" Name="MoveProfJerk_CutProfile_ReduceAccDec.pMoveProf"/>
			pVelReduction 	: ^LREAL;			//! <Variable Comment="Amount of velocity to be cut from the Acceleration / Deceleration section.&#13;&#10;&#13;&#10;For further information refer to internal documentation." Name="MoveProfJerk_CutProfile_ReduceAccDec.pVelReduction"/>
			dSections 	: DINT;			//! <Variable Comment="This value indicates whether to cut the velocity from the Accel or Decel Section of the profile.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;dSections = 0 -&gt; Cut form the Accel Section.&#13;&#10;dSections = 1 -&gt; Cut form the Decel Section." Name="MoveProfJerk_CutProfile_ReduceAccDec.dSections"/>
		END_VAR
		VAR_OUTPUT
			RetCode 	: t_e_LMCMath_Retcodes;			//! <Variable Comment="Return code of this function is passed straight through to the _LMCMathFunctions::CalcMoveProf_Jerk() function and the meaning of each possible value is discussed in the comments of that function." Name="MoveProfJerk_CutProfile_ReduceAccDec.RetCode"/>
		END_VAR;
				//! <Function Comment="This method is used internally by the MoveProfJerk_CalcProfile() method to decrease the distance that a zero-cruise profile travels.&#13;&#10;The distance is taken from the wedge and trapezium sections of the profile.&#13;&#10;&#13;&#10;When this method is executed it is essential that all velocities and positions in the profile are up to date, the _LMCMathFunctions::MoveProfJerk_UpdateVS() method can be used for this.&#13;&#10;&#13;&#10;pMoveProf is required and must have been generated by the MoveProfJerk_CalcProfile() method.&#13;&#10;pCurrentDist can be left to NIL - in which case the method will use the MoveProfJerk_CalcDist() method to calculate the current travel distance.&#13;&#10;pTargetDist must be set.&#13;&#10;&#13;&#10;For details reagrding the paramaters see the comment section of each." Name="MoveProfJerk_ShrinkProfile"/>
	FUNCTION MoveProfJerk_ShrinkProfile
		VAR_INPUT
			pMoveProf 	: ^t_st_LMC_MoveProf_Jerk;			//! <Variable Comment="This input parameter should point to the Zero-Cruise Profile Structure that should be shrinked&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pMoveProf &lt;&gt; NIL." Name="MoveProfJerk_ShrinkProfile.pMoveProf"/>
			pCurrentDist 	: ^LREAL;			//! <Variable Comment="This input parameter should point to a variable containing the current distance of the profile if it is available, if not available, this value will be automatically calculated.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pCurrentDist &lt;&gt; NIL -&gt; The value pointed to is used as the distance that the profile currently travels.&#13;&#10;pCurrentDist = NIL -&gt; The current travel distance of the profile is calculated automatically." Name="MoveProfJerk_ShrinkProfile.pCurrentDist"/>
			pTargetDist 	: ^LREAL;			//! <Variable Comment="This input parameter should point to a variable containing the Target Distance that the profile should travel.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pTargetDist &lt;&gt; NIL." Name="MoveProfJerk_ShrinkProfile.pTargetDist"/>
		END_VAR
		VAR_OUTPUT
			RetCode 	: t_e_LMCMath_Retcodes;			//! <Variable Comment="The RetCode indicates the success of the calculation:&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;RetCode = LMCMathRet_InputErr -&gt; 1. pMoveProf or pTargetDist is not set. 2. The current profile travel distance is smaller than the Target Distance specified, the profile therefor cannot be shrinked further." Name="MoveProfJerk_ShrinkProfile.RetCode"/>
		END_VAR;
				//! <Function Comment="This method steps over the entire profile and sets the velocity and position in each of the points." Name="MoveProfJerk_UpdateVAS"/>
	FUNCTION GLOBAL MoveProfJerk_UpdateVAS
		VAR_INPUT
			pMoveProf 	: ^t_st_LMC_MoveProf_Jerk := NIL;			//! <Variable Comment="This input parameter should point to the profile to step over.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;pMoveProf &lt;&gt; NIL." Name="MoveProfJerk_UpdateVAS.pMoveProf"/>
			bdUpdateValues 	: BDINT := 16#00000007;			//! <Variable Comment="This BDINT can be set to indicate the values to be calculated:&#13;&#10;Bit 0 -&gt; Velocity&#13;&#10;Bit 1 -&gt; Acceleration&#13;&#10;Bit 2 -&gt; Position&#13;&#10;&#13;&#10;If the value is not set (Parameter not passed), all values are calculated (16#00000007)." Name="MoveProfJerk_UpdateVAS.bdUpdateValues"/>
			udUpTo 	: UDINT := 9;			//! <Variable Comment="This value can be set to indicate the point in the profile that must be calculated to. &#13;&#10;The value is 1 indexed, so that (1) calculates only the first point.&#13;&#10;If the value is not set, all points are calculated (9).&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;0 &lt;= udUpTo &lt;= 9" Name="MoveProfJerk_UpdateVAS.udUpTo"/>
		END_VAR
		VAR_OUTPUT
			RetCode 	: t_e_LMCMath_Retcodes;			//! <Variable Comment="Return code indicating the success of the calculation.&#13;&#10;&#13;&#10;Possible Values:&#13;&#10;LMCMathRet_InputErr -&gt; The pMoveProf pointer is not set, or the value passed to udUpTo &gt; 9." Name="MoveProfJerk_UpdateVAS.RetCode"/>
		END_VAR;
				//! <Function Comment="This function generates a Zero Cruise Profile for the given parameters:&#13;&#10;- Start and End Velocity&#13;&#10;- Start and End Accel&#13;&#10;- Constant Jerk&#13;&#10;&#13;&#10;The Delivered Move Profile contains the Profile Times, Velocities and Accelerations. The Distances are NOT calculated, to determine these, the call to MoveProfJerk_ZeroCruiseProf() can be succeeded by a call to MoveProfJerk_UpdateVAS()." Name="MoveProfJerk_ZeroCruiseProf"/>
	FUNCTION MoveProfJerk_ZeroCruiseProf
		VAR_INPUT
			pVs 	: ^LREAL;
			pVe 	: ^LREAL;
			pAs 	: ^LREAL;
			pAe 	: ^LREAL;
			pVmax 	: ^LREAL;
			pAmax 	: ^LREAL;
			pJerk 	: ^LREAL;
			pMoveProfile 	: ^_LMCMathFunctions::t_st_LMC_MoveProf_Jerk;
		END_VAR
		VAR_OUTPUT
			RetCode 	: t_e_LMCMath_Retcodes;
		END_VAR;
				//! <Function Comment="This method can be used to limit a LREAL value in place." Name="RangeLimit"/>
	FUNCTION GLOBAL RangeLimit
		VAR_INPUT
			pInVal 	: ^LREAL;			//! <Variable Comment="Pointer to the value to be limited, the value will be modified in place" Name="RangeLimit.pInVal"/>
			lrLowerLim 	: LREAL;			//! <Variable Comment="Lower limit to use in the range. If the value is limited by this bound the return code delivers 2." Name="RangeLimit.lrLowerLim"/>
			lrUpperLim 	: LREAL;			//! <Variable Comment="Upper limit to use in the range. If the value is limited by this bound the return code delivers 1." Name="RangeLimit.lrUpperLim"/>
		END_VAR
		VAR_OUTPUT
			dValChanged 	: DINT;			//! <Variable Comment="Whether the value has been modified:&#13;&#10;-2: The limits are inverted or equal.&#13;&#10;-1: The Input value pointer is invalid.&#13;&#10;0: The input value was inside the provided range.&#13;&#10;1: The input value was limited by the upper limited.&#13;&#10;2: The input value was limited by the lower limited." Name="RangeLimit.dValChanged"/>
		END_VAR;
				//! <Function Comment="This method can be used to convert a value in Radians to Degrees." Name="Rad2Deg"/>
	FUNCTION GLOBAL Rad2Deg
		VAR_INPUT
			pVal 	: ^LREAL;			//! <Variable Comment="Pointer to the value to be converted, the value will be converted in place." Name="Rad2Deg.pVal"/>
		END_VAR
		VAR_OUTPUT
			bOK 	: BOOL;			//! <Variable Comment="True: The Value was converted.&#13;&#10;False: The pointer to the input value was invalid." Name="Rad2Deg.bOK"/>
		END_VAR;
				//! <Function Comment="This method can be used to convert a value in Degrees to Radians." Name="Deg2Rad"/>
	FUNCTION GLOBAL Deg2Rad
		VAR_INPUT
			pVal 	: ^LREAL;			//! <Variable Comment="Pointer to the value to be converted, the value will be converted in place." Name="Deg2Rad.pVal"/>
		END_VAR
		VAR_OUTPUT
			bOK 	: BOOL;			//! <Variable Comment="True: The Value was converted.&#13;&#10;False: The pointer to the input value was invalid." Name="Deg2Rad.bOK"/>
		END_VAR;
  //Tables:
	FUNCTION @STD
		VAR_OUTPUT
			ret_code	: CONFSTATES;
		END_VAR;
	FUNCTION GLOBAL TAB @CT_;
END_CLASS;

//}}LSL_DECLARATION


FUNCTION GLOBAL TAB _LMCMathFunctions::@CT_
0$UINT,
2#0100000000000000$UINT, //TY__LMCMATHFUNCTIONS
1$UINT, 75$UINT, (SIZEOF(::_LMCMathFunctions))$UINT, 
1$UINT, 0$UINT, 0$UINT, 
TO_UDINT(838927485), "_LMCMathFunctions", //Class
TO_UDINT(0), 0, 0$UINT, 0$UINT, //Baseclass
//Servers:
(::_LMCMathFunctions.ClassSvr.pMeth)$UINT, _CH_CMD$UINT, 2#0000000000000000$UINT, TO_UDINT(619352855), "ClassSvr", 
//Clients:
END_FUNCTION


#define USER_CNT__LMCMathFunctions 0

TYPE
	_LSL_STD_VMETH	: STRUCT
			CmdTable	: CMDMETH;
			UserFcts	: ARRAY[0..USER_CNT__LMCMathFunctions] OF ^Void;
	END_STRUCT;
END_TYPE

FUNCTION _LMCMathFunctions::@STD
	VAR_OUTPUT
		ret_code	: CONFSTATES;
	END_VAR

	ret_code := C_OK;

END_FUNCTION

//{{LSL_IMPLEMENTATION
//{{LSL_ENCRYPTION 16#800
[encoded data, 196704 characters]