Daz script sin() and cos() functions
I've started playing with scripts. What I want to do is rotate an object - that bit I've got working (i.e. writing different Xrot values to successive frames). But it rotates about the bottom of the object, rather than its centre - so I've got to apply deltas to the Y and Z transforms to correct the apparant centre of rotation - and for that I need to use sin() and cos(). Except I get a runtime error "ReferenceError: Can't find variable: sin". So I assume I haven't understood the syntax correctly. I have the angle in radians in a DzVec3 variable (x, y, z) called ang (ang.x is limited to +/- PI), and the line which throws the error is as follows:
var deltaY = -(217 * sin(ang.x));
(217 being the distance from the base of the object being rotated to my required centre of rotation).
Comments
Moved to the scripting forum.
You need the Math global object - Math.sin( number ) etc.
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/math
Yes, thank you, that's it. (My mind is too stuck in C syntax).