[Closed] coordsys
I’m a little confused as to how to get “in coordsys” to work for what I want.
This line of code works how I think it should. It positions point2 to 100 units away from point 1 using point1’s coordinate system:
in coordsys $Point01 $point02.pos = $Point01.pos + [0,100,0]
This is the same code but with an intermediate step to assign the value to a variable and doesn't do what I need, positions point2 in world space
in coordsys $Point01 thePos = $Point01.pos + [0,100,0]
$point02.pos = thePos
And I'm not sure why this doesn't work either
$point02.pos = in coordsys $Point01 $Point01.pos + [0,100,0]
What I'm actually trying to do is assign a value to a variable that is a worldspace position value calculated using an offset value from objectA using objectA's coordinate system and just can't wrap my head around how. I'm sure I'm close, but no joy yet. can anyone help me out here?
I tend not to use the coordsys context. Not that its broken or anything, I think that I’m just more comfortable with vector math.
Since you are just moving along point1’s local Y axis, you can use vector math to get your new point quite easily:
newPoint = $point1.pos + 100 * normalize $point1.transform[2]
Cheers, that does exactly what I want. I really should learn more about matrix and vector maths.
The second one doesn’t work as you are using a return and that breaks the coordsys scope before setting the position. Wrap your code in brackets and you should be fine, try one of these to add a new line in the code:
in coordsys $Point01 (thePos = $Point01.pos + [0,100,0]
$point02.pos = thePos)
in coordsys $Point01 (thePos = $Point01.pos + [0,100,0];$point02.pos = thePos)
Otherwise thePos is set to [0,100,0], it then sets the position in a new line outside of the coordsys scope. So the position of $Point02.pos = [0,100,0]. Atleast that is what I am getting in my tests.
-Eric