Action:
|
Evaluates a given law or law expression with the specified input and returns a position or a par-pos.
|
|
Filename:
|
kern/kern_scm/law_scm.cxx
|
|
Syntax:
|
(law:eval-position law input)
|
|
Arg Types:
|
law
|
law | string | real | position |
|
|
|
par-pos | gvector
|
|
input
|
(entity | (entity ...)) | real | gvector |
|
|
|
position | par-pos
|
|
Returns:
|
position | par-pos
|
|
Errors:
|
The law must return 2 or 3 values.
|
|
Description:
|
This Scheme extension evaluates the
law at the given input. It is the same as
law:eval except that it returns either a
position or a
par-pos instead of a real or list of reals. The output dimension of
law has to be two (2) or three (3). The result is a
par-pos when the output dimension is two, and
position when it is three.
|
|
|
law can be a
law Scheme type or a string enclosed by double quotation marks.
law can be any combination of law functions.
|
|
|
input specifies the value(s) for evaluating the law.
|
|
Example:
|
; law:eval-position
|
|
; Create a new law.
|
|
(define law1 (law "vec(x,x^2,-cos(x))"))
|
|
;; law1
|
|
; Evaluate the given law at 1.5 radians
|
|
(law:eval-position law1 2)
|
|
;; #[position 2 4 0.416146836547142]
|
|
(define law2 (law "vec(x^2, y, 3 * z)"))
|
|
;; law2
|
|
; Evaluate the second law at some input values.
|
|
(law:eval-position law2 (list 2 3 4))
|
|
;; #[position 4 3 12]
|
|
(define law3 (law "vec(a3^2,a2,a4)"))
|
|
;; law3
|
|
; When evaluating this, the law function has 4 as its
|
|
; highest input index. Thus, the input list has to
|
|
; have at least four items. In law3, input A1 is
|
|
; not used in the law function, so the first element
|
|
; of list is not used.
|
|
; a3=3, a2=2, and a4=4. (a1=1).
|
|
(define law4 (law "vec(a3^2,a4)"))
|
|
;; law4
|
|
(law:eval-position law3 (list 1 2 3 4))
|
|
;; #[position 9 2 4]
|
|
(law:eval law3 (list 1 2 3 4))
|
|
;; (9 2 4)
|
|
(law:eval-position law4 (list 1 2 3 4))
|
|
;; #[par-pos 9 4]
|