MotionView User's Guide

2D Curves

2D Curves

Previous topic Next topic Expand/collapse all hidden text  

2D Curves

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

This section describes the 2D Curve entity of MotionView and shows the various usage, creation, and editing methods.

Theory/Background

2D Curves are reference curves or splines that can be used to define non-linear Forces, Spring Dampers, Motions, etc. in a multi-body model.

curves_entity_2d_example_mv

2D Curve in MotionView

The are two types of 2D curves available in MotionView:

2D Cartesian

2D Cartesian curves or 2D splines consist of two vectors.  Both vectors must be of the same length (or in other words, should have the same number of data points).

2D Parametric

A parametric curve is defined in terms of one free parameter, u. In a 2D Parametric curve C is defined with respect to a coordinate system OXYZ. The coordinates of any arbitrary point on the curve P, as measured in OXYZ, can be represented uniquely in terms of the free parameter u with three functions, f(u), g(u), and h(u), that define the x-, y- and z-coordinates of P. The extent of the curve is governed by the start and end values of u. This is a parametric representation for a curve.  The 2D Parametric curve type available in MotionView is useful in pre-processing such curves.

Creating and Editing 2D Curves

To learn how to add a 2D Curve to a model, please see the Curves topic.

2D Cartesian Curves

hmtoggle_plus1To define a 2D Cartesian curve:
1.Once an Curve has been added to the model using any of the entity creation methods, the panel for the Curve will be displayed in the panel area.

curves_panel_2d_cartesian_mv

Curve Panel - Properties Tab

2.From the first drop-down menu diagram_number_one_round_mv, select 2D Cartesian.
3.From the second drop-down menu diagram_number_two_round_mv, select the curve vector type to define the curve properties.  Each column for the curve can be defined using either of the following vector types:
File
Math
Values

To know more about how define the curve data using the curve vector types, please refer to the Vector Types topic.

A 2D Curve can also be defined as a User-Defined Curve. Refer to User-Defined topic for additional details.

4.The property of the curve can be defined based on the vector type selected.
5.After defining the properties, click the Show Curve button to view the curve.

2d_cartesian_curve_example_mv

6.To export the added curve, click the Export Curve button.
7.To define the curve attributes, click on the Attributes tab.

2d_cartesian_curve_panel_attributes_tab_mv

8.To enable Linear Extrapolation, activate the check box.

Linear Extrapolation enables the solver to extrapolate the curve linearly when the computed value for the independent variable goes out of the specified bounds.

9.For curve visualization options, click on the Visualization tab.

2d_cartesian_curve_panel_visualization_tab_mv

10.The Show Curve button on the Visualization tab displays the 2D curve on a graph.
11.The Extrapolate check box displays an extrapolated curve.  The percentage of extrapolation can also be controlled on the panel.
12.The Interpolate check box displays an interpolated curve. The interpolation is based on the selected method of interpolation (Linear, Cubic, or Akima). The default is Cubic interpolation.
13.The Symbols check box turns the display of the symbols on the curve data points on or off.
14.To view the changes made in steps 2 to 4 (above), you will need to click the Show Curve button again.
hmtoggle_plus12D Cartesian curve in MDL (Model Definition Language)

Syntax:

*Curve(crv_name, "crv_label", 2D,

                             CARTESIAN,

                            [WRITE|NOWRITE],

                            [CONTROL_POINTS|CURVE_POINTS],

                             OPEN|CLOSED])

Example:

*Curve( crv_2d_cart, "2D_Cartesian", 2D, CARTESIAN, WRITE, CURVE_POINTS, OPEN )

The syntax to define the curve data:

*SetCurve(crv_name, Block-X, Block-Y, LIN_EXTRAP )

Block-X and Block-Y can be of the following three types:

FILE: "[path]/filename", datatype, request, component

MATH: expr

VALUE: numpts, v1, v2, v3, ..., vn

Example:

*SetCurve( crv_2d_cart,                FILE, "curve.csv", "Unknown", "Block 1", "column0", FILE, "curve.csv", "Unknown", "Block 1", "column0" )

To understand the complete syntax of the MDL statements mentioned above, please refer to the following MotionView MDL Reference Guide topics: *Curve() and *SetCurve().

hmtoggle_plus12D Cartesian curve in XML Format

MotionSolve writes out the 2D Cartesian curve as Reference_Spline when exported to the MotionSolve XML format.

Syntax:

<Reference_Spline

     id                  = "integer"

   [ label               = "string" ]

   [ linear_extrap       = { "TRUE" | "FALSE" } ]

  {

     usrsub_dll_name     = "valid_path_name"

     usrsub_fnc_name     = "custom_fnc_name" >

   |

     script_name         = valid_path_name

     interpreter         = "PYTHON" | "MATLAB"

     usrsub_fnc_name     = "custom_fnc_name" >

 

     file_name           = "valid_file_name"

   [ block_name          = "valid_block_name" ]

 

   | num_x               = "integer"

   [ num_z               = "integer" ] >

    < !-- X       Y for Z1   Y for Z2         Y for ZNUM_Z -->

         x1         y1,1         y1,2       ...        y1,NUM_Z 

         x2         y2,1        y2,2       ...       y2,NUM_Z 

       ...

       XNUM_X        yNUM_X,1      yNUM_X,2     ...    yNUM_X,NUM_Z 

 }

    <!—- Z values -->

      Z1   Z2 ...   ZNUM_Z

</Reference_Spline>

In case of the 2D Cartesian curve, the model statement will be as shown below:

<Reference_Spline

    id                  = "301001"

    label               = "2D_Cartesian"

    num_x               = "9"

    linear_extrap       = "FALSE">

  1.0000000E+00   1.0000000E+00

  2.0000000E+00   2.0000000E+00

  3.0000000E+00   3.0000000E+00

  4.0000000E+00   4.0000000E+00

  5.0000000E+00   5.0000000E+00

  6.0000000E+00   6.0000000E+00

  7.0000000E+00   7.0000000E+00

  8.0000000E+00   8.0000000E+00

  9.0000000E+00   9.0000000E+00

 </Reference_Spline>

To understand the complete syntax of the Reference_Spline XML model statement, please refer to the MotionSolve Reference Guide topic for Reference_Spline.

hmtoggle_plus12D Cartesian curve in Tcl Format

In MotionView, Tcl can be used to add any MDL entities to the model.  There are two Tcl commands that can be used to add an entity:

Syntax:

mdlmodel_handle InterpretEntity new_handle keyword varname label

In case of the 2D Cartesian curve the statement will look as shown below:

mdlmodel_handle InterpretEntity curve_handle Curve crv_2d_cart "\"2D Cartesian \"" "2D" "CARTESIAN" "WRITE" "CURVE_POINTS" "OPEN";

Syntax: 

mdlmodel_handle InterpretSet keyword tokens

In case of the 2D Cartesian curve the statement will look as shown below:

mdlmodel_handle InterpretSet SetCurve crv_2d_cart "FILE" "\"D:/Documents/curve.csv \"" "\"Unknown\"" "\"Block 1\"" "\"X\"" "FILE" "\"D:/Documents/curve.csv\"" "\"Unknown\"" "\"Block 1\"" "\"Y\"" "LIN_EXTRAP";

The InterpretEntity command is used to add entities to the model and the InterpretSet command is used to set the entity properties.  To understand the complete usage and syntax of these commands, please refer to the InterpretEntity and InterpretSet topics located within the HyperWorks Desktop Reference Guide.

Note - When using the InterpretEntity and InterpretSet commands, it is important to also use the Evaluate command in order for the changes to take effect immediately.

To learn how to create a complete model using Tcl commands, please refer to tutorial MV-1040: Model Building Using Tcl.

2D Parametric Curves

hmtoggle_plus1To define a 2D Parametric curve:

In the case of a Parametric curve, a parameter U will be introduced more arbitrarily, mainly as a tool for describing the curve. One often uses the language of a point "moving" along the curve even in more abstract situations where the curve does not have a mechanical interpretation.

An example use case for using 2D parametric curves is discussed below. The data of the u parameter of the curve is available in a File vector type.  The X and Y vectors of the 2D Parametric curve are derived from the File based U vector.

The example curve could be represented like this:

U Vector –
File Reference Values

X Vector –
Math Expression

Y Vector –
Math Expression

1

cos(crv_2d_para.u)

sin(crv_2d_para.u)

2

3

4

5

The values for the X and Y are computed using the Math expressions, by taking the u parameter as the reference values.

X Value

Y Value

5.4030231E-01

8.4147098E-01

-4.1614684E-01

9.0929743E-01

-9.8999250E-01

1.4112001E-01

-6.5364362E-01

-7.5680250E-01

2.8366219E-01

-9.5892427E-01

1.Once an Curve has been added to the model using any of the entity creation methods, the panel for the curve will be displayed in the panel area.

2d_parametric_curve_panel_example_mv

Curve Panel - Properties Tab

2.From the first drop-down menu diagram_number_one_round_mv, select 2D Parametric.
3.From the second drop-down menu diagram_number_two_round_mv, select the curve vector type to define the curve properties.  Each column for the curve can be defined using either of the following vector types:
File
Math
Values

To know more about how define the curve data using the curve vector types, please refer to the Vector Types topic.

4.The property of the curve can be defined based on the vector type selected.
5.To define the curve attributes, click on the Attributes tab.

2d_parametric_curve_panel_attributes_tab_mv

6.To enable Linear Extrapolation, activate the check box.
hmtoggle_plus12D Parametric curve in MDL (Model Definition Language)

Syntax:

*Curve(crv_name, "crv_label", 2D,

                             PARAMETRIC,

                            [WRITE|NOWRITE],

                            [CONTROL_POINTS|CURVE_POINTS],

                            OPEN|CLOSED])

Example:

*Curve( crv_2d_para, "2D_Parametric", 2D, PARAMETRIC, WRITE, CURVE_POINTS, OPEN )

The syntax to define the curve data:

*SetCurve(crv_name, Block-U, Block-X, Block-Y, LIN_EXTRAP )

Block-X and Block-Y can be of the following three types:

FILE: "[path]/filename", datatype, request, component

MATH: expr

VALUE: numpts, v1, v2, v3, ..., vn

Example:

*SetCurve( crv_2d_para, FILE, "curve.csv", "Unknown", "Block 1", "column0", MATH, cos(crv_2d_para.u), MATH, sin(crv_2d_para.u) )

To understand the complete syntax of the MDL statements mentioned above, please refer to the following MotionView MDL Reference Guide topics: *Curve() and *SetCurve().

hmtoggle_plus12D Parametric curve in XML Format

MotionSolve writes out the 2D Cartesian curve as Reference_Spline when exported to the MotionSolve XML format.  The syntax for the 2D Parametric curve is same as the 2D Cartesian curve.  While getting exported to XML, MotionSolve writes out the values for X and Y by taking the U parameter as the reference value.  The extent of the curve is governed by the number of U points (that is, the start and end points).

Syntax:

<Reference_Spline

     id                  = "integer"

   [ label               = "string" ]

   [ linear_extrap       = { "TRUE" | "FALSE" } ]

  {

     usrsub_dll_name     = "valid_path_name"

     usrsub_fnc_name     = "custom_fnc_name" >

   |

     script_name         = valid_path_name

     interpreter         = "PYTHON" | "MATLAB"

     usrsub_fnc_name     = "custom_fnc_name" >

 

     file_name           = "valid_file_name"

   [ block_name          = "valid_block_name" ]

 

   | num_x               = "integer"

   [ num_z               = "integer" ] >

    < !-- X       Y for Z1   Y for Z2         Y for ZNUM_Z -->

         x1         y1,1         y1,2       ...        y1,NUM_Z

         x2         y2,1        y2,2       ...       y2,NUM_Z

       ...

       XNUM_X        yNUM_X,1      yNUM_X,2     ...    yNUM_X,NUM_Z 

 }

    <!—- Z values -->

      Z1   Z2 ...   ZNUM_Z

</Reference_Spline>

To understand the complete syntax of the Reference_Spline XML model statement, please refer to the MotionSolve Reference Guide topic for Reference_Spline.

hmtoggle_plus12D Parametric curve in Tcl Format

In MotionView, Tcl can be used to add any MDL entities to the model.  There are two Tcl commands that can be used to add an entity:

Syntax:

mdlmodel_handle InterpretEntity new_handle keyword varname label

In case of the 2D Parametric curve the statement will look as shown below:

mdlmodel_handle InterpretEntity curve_handle Curve crv_2d_para "\"2D Parametric \"" "2D" "PARAMETRIC" "WRITE" "CURVE_POINTS" "OPEN";

Syntax: 

mdlmodel_handle InterpretSet keyword tokens

In case of the 2D Parametric curve the statement will look as shown below:

mdlmodel_handle InterpretSet SetCurve crv_2d_para "FILE" "curve.csv" "MATH" "sin(crv_2d_para.u) " "MATH" "cos(crv_2d_para.u)" "LIN_EXTRAP";

The InterpretEntity command is used to add entities to the model and the InterpretSet command is used to set the entity properties.  To understand the complete usage and syntax of these commands, please refer to the InterpretEntity and InterpretSet topics located within the HyperWorks Desktop Reference Guide.

Note - When using the InterpretEntity and InterpretSet commands, it is important to also use the Evaluate command in order for the changes to take effect immediately.

To learn how to create a complete model using Tcl commands, please refer to tutorial MV-1040: Model Building Using Tcl.

Example Model

The following example shows the 2D curve entity in various formats:

hmtoggle_plus12DCurves.mdl

*BeginMDL( the_model, "Model", "12.0.110.20" )

 

 *StandardInclude(FILE)

 *SetCurrentSolverMode(MotionSolve)

 *Point( p_a, "Point A" )

 *Body( b_a, "Body A", p_a, , , ,  )

 *Set( b_a.usecm, true )

 *ActionOnlyForce( frc_cart_crv, "Force_Cartesian_Curve", TRANS, b_a, p_a, Global_Frame )

 *ActionOnlyForce( frc_para_crv, "Force_Parametric_Curve", TRANS, b_a, p_a, Global_Frame )

 

// Example for 2D Cartesian Curve

 *Curve( crv_2d_cart, "2D_Cartesian", 2D, CARTESIAN, WRITE, CURVE_POINTS, OPEN )

 *SetCurve( crv_2d_cart,                FILE, "D:/Documents/curve.csv", "Unknown", "Block 1", "column0", FILE, "D:/Documents/curve.csv", "Unknown", "Block 1", "column0" )

 

// Example for a 2D Parametric Curve

 *Curve( crv_2d_para, "2D_Parametric", 2D, PARAMETRIC, WRITE, CURVE_POINTS, OPEN )

 *SetCurve( crv_2d_para,                FILE, "D:/Documents/curve.csv", "Unknown", "Block 1", "column0", MATH, cos(crv_2d_para.u), MATH, sin(crv_2d_para.u) )

 *SetForce( frc_cart_crv,               CRV, crv_2d_cart, , , LIN, , LIN )

 *SetForce( frc_para_crv,               CRV, crv_2d_para, , , LIN, , LIN )

 *SetActiveAnalysis( NONE )

*EndMDL()

See Also:

Curves Panel

Adding and Removing Entities

*Curve() (MDL Model Statement)

*SetCurve() (MDL Model Statement)

Reference_Spline (XML Command)

InterpretEntity (Tcl Command)

InterpretSet (Tcl Command)