Ok I got this far - which seems to be good except for some reason my X-coordinate result is not ACCURATE! There's a mistake somewhere...
Does anyone know what I've done wrong here:
(I'm sure some of you are laughing out loud ;)pp )
Thanks,
Danny
Does anyone know what I've done wrong here:
(I'm sure some of you are laughing out loud ;)pp )
;I want to rotate the 'local offset' around the global coordinate - by using the global rotation angles. Graphics3D 800,600,0,2 Cls Color 255,255,255 ;original GLOBAL COORDINATE ox# = -239.475 oy# = 2.07104 oz# = -81.7197 ;original GLOBAL ROTATION xr# = 9.06404 yr# = -145.508 zr# = 0.00 ;original LOCAL OFFSET offx# = 0.0 offy# = 0.1 offz# = 0.1 ;Transformation using TFormPoint() tmp = CreatePivot() PositionEntity tmp, ox,oy,oz, 1 ; global pos RotateEntity tmp, xr,yr,zr, 1 ; global rot TFormPoint offx,offy,offz, tmp, 0 ; local offset to world coords ok1x# = TFormedX() ok1y# = TFormedY() ok1z# = TFormedZ() Color 160,160,160 Print "Original coordinate: "+ox+", "+oy+", "+oz Print "" Color 255,255,255 Print "TFormed coordintes : "+ok1x+", "+ok1y+", "+ok1z+" = what I NEED!" Print "" ; ROTATE THE LOCAL OFFSET around GLOBAL ANGLE (attempt) x# = offx# y# = offy# z# = offz# ;rotate offset around X axis newy# = y# * Cos#(xr#) - z# * Sin#(xr#) newz# = y# * Sin#(xr#) + z# * Cos#(xr#) y# = newy# z# = newz# ;rotate offset around Y axis newx# = z# * Sin#(yr#) + x# * Cos#(yr#) newz# = z# * Cos#(yr#) - x# * Sin#(yr#) x# = newx# z# = newz# ;rotate offset around Z axis newx# = x# * Cos#(zr#) - y# * Sin#(zr#) newy# = x# * Sin#(zr#) + y# * Cos#(zr#) x# = newx# y# = newy# ;add global coordinates to rotated offset x# = x# + ox# y# = y# + oy# z# = z# + oz# Print "transformed coords : "+x+", "+y+", "+z+" = what I GOT :(" Print "" Color 255,50,50 Print "INACCURACY (xyz) : "+(ok1x-x)+", "+(ok1y-y)+", "+(ok1z-z) Print "" Print "" WaitKey() End
Thanks,
Danny