# Curve

Model ElementCurve defines a parametric curve in 3D space.

## Class Name

Curve

## Description

A parametric curve has one free parameter, u, and three associated functions f(u), g(u) and h(u). For every value, u=u*, f(u*), g(u*), and h(u*) represent the coordinates of a point in space. As u is swept from its minimum to maximum value, a curve in 3D space is generated. For additional information on the definition of Curve, please see the Description and the Comments section of Reference_ParamCurve.

## Attribute Summary

Name | Property | Modifiable by command? | Designable? |
---|---|---|---|

id | Int () | ||

label | Str () | ||

matrix | Reference ("Matrix") | Yes | FD Only |

curve_points | Bool () | Yes | |

closed | Bool () | Yes | |

minpar | Double (-1.0) | ||

maxpar | Double (1.0) | ||

routine | Routine () | FD Only | |

script | Script () | ||

function | Function ("CURSUB") | FD Only |

## Usage

Curves are available in three different forms.

```
#1: Curve data provided in a Matrix
Curve (matrix=objMatrix, type=string, curve_points=Boolean, optional_attributes)
#2. Curve specified in a compiled user-written subroutine
Curve (function=userString, routine=string, type=string, optional_attributes)
#3. Curve specified in a Python functionCurve (function=userString, routine=functionPointer, type=string, curve_points=boolean, optional_attributes)
```

## Attributes

`matrix`- Reference to an existing matrix object.
`type`- String
`curve_points`- Boolean

`function`- String
`routine`- String
`type`- String
`minpar`- Double
`maxpar`- Double

`function`- String
`routine`- Pointer to a callable function in Python.
`type`- String
`minpar`- Double
`maxpar`- Double

`id`- Integer
`label`- String

## Example

```
x = a * (t - sin(t))
y = a * (1-cos(t))
```

`"t"`is the independent parameter. The cycloid is shown in the image below.

- Define a parametric curve using a matrix.The statement defining the cycloid described above has the following curve attributes:
- The Curve is open
- The independent parameter
`t`starts at zero - The independent parameter
`t`ends at 5 - The curve points are specified in the Matrix object mat23

The corresponding MotionSolve Python specification is:`# Note, since curve_points=True, MINPAR=-1 and MAXPAR=+1. # This range in u will accommodate all the data provided in the matrix. curve1 = Curve (type="OPEN", curve_points=True, matrix=mat23)`

- Define a parametric curve in a python function.This example shows how to specify exactly the same for implementation in a user-defined subroutine written in Python:
`# The cycloid function saved in file: cycloid.py from msolve import sin, cos def cycloid (id, par, npar, t, iord, iflag): a = par[0] if iord == 0: x = a * (t - sin(t)) y = a * (1 - cos(t)) z = 0.0 elif iord == 1: x = a * (1 - cos(t)) y = a * sin(t) z = 0.0 else: x = a * sin(t) y = a * cos(t) z = 0.0 return [x, y, z]`

The corresponding MotionSolve Python specification is:`curve2 = Curve (function="USER(1)", routine=cycloid, type="OPEN", minpar=0, maxpar=6)`

## Comments

- See Properties for an explanation about what properties are, why they are used, and how you can extend these.
- For a more detailed explanation about Curve, see Reference: ParamCurve.