law
List of: Scheme Extensions
Subjects: Laws
Contents: Kernel

Action: Creates a law Scheme data type composed of one or more law functions.

Filename: kern/kern_scm/law_scm.cxx

APIs: api_str_to_law

Syntax: (law {"law-functions" | type} [law-data]*)

Arg Types: "law-functions" string

type law | real | position | par-pos |


gvector

law-data law | real | position | par-pos |


gvector | transform | edge | wire

Returns: law

Description: The law Scheme extension creates a law Scheme data type composed of one or more law functions.


"law-functions" is a string specifying law function enclosed in quotation marks.


The law functions are very similar to common mathematical notation and to the adaptation of mathematical notation for use in computers. The valid syntax for the character strings are given in the law function templates.


The strings used to define laws are not case-sensitive, but when returned from a law function, the lower-case letters are converted to upper-case letters. Only laws that are used to define the geometry, such as wire-body:offset and sweep:law, are stored in a save file.


The optional argument defined in law-data must agree with the items specified within law-functions in type, number, and order. For example, if the law-functions calls for law1, edge2, and wire3, the input must be a list with at least three items: the first item must be a law; the second item must be an edge; and the third item must be a wire. The index number of the item within the law function specifies its ordering in the input list.


position, par-pos, or gvector may be used as law-data, which correspond to the law# and are converted into the "vec" law function.

Example: ; law

; Create a new law.

(define law1 (law "x+x^2-cos(x)"))

;; law1

; Evaluate the given law at 1.5 radians

(law:eval law1 1.5)

;; 3.6792627983323




; Another example using law data

; This creates a law that returns the position

; of an edge with its position mapped to the

; closed interval [0,1].

; Create an edge.

(define edge1 (edge:linear (position 0 0 0)


(position 40 40 0)))

;; edge1

(define edge-law (law


"map(cur(edge1)),edge1)" edge1))

;; edge-law
PDF/KERN/14SCI.PDF
HTM/DATA/KERN/KERN/14SCI/0002.HTM