PDA

View Full Version : silly function problem


stuh505
12-11-2008, 07:25 PM
I made a function:

function quatrotate pt qt =
(
local qp = (quat pt.x pt.y pt.z 0)
local res = (qt * qp) * (inverse qt)
return [res.x, res.y, res.z]
)

I tested each step to make sure it works in the MAXScript listener:


pt = [1,0,0]
[1,0,0]
qt = cam.rotation
(quat 0 -0.226418 0 0.97403)
qp = (quat pt.x pt.y pt.z 0)
(quat 1 0 0 0)
res = (qt * qp) * (inverse qt)
(quat 0.89747 0 0.441075 0)
[res.x, res.y, res.z]
[0.89747,0,0.441075]

^^ That works correctly.

Now I try to call the function on the same inputs:

quatrotate [1,0,0] cam.rotation
-- Error occurred in quatrotate(); filename: D:\Professional & Academic\Professional\Shape from Video\PrintExtrinsic.ms; position: 94
-- Frame:
-- pt: [1,0,0]
-- qt: (quat 0 -0.226418 0 0.97403)
-- res: undefined
-- qp: (quat 1 0 0 0)
-- Unable to convert: [1,0,0] to type: Quaternion

How did I mess that up?

Also, second question:

Is there any way I can concatenate a Point3 + float to make a Quat, other than explicitly breaking it into components the way I did? And vice versa, to take the first 3 elements of a quat and store into Point3?

Kramsurfer
12-11-2008, 10:36 PM
Defined and tried your function.. it worked fine...

Restart Max... perhaps the function, for an old try, is still defined and not redefining..

JHN
12-12-2008, 07:58 AM
Works here too, max2009 sp1 x64.
-Johan

CGTalk Moderation
12-12-2008, 07:58 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.