Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

3d rotational vector to 4-float VRML rotation node
 

Dave Coventry




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  
Hi,

I need help in translating a vector rotation element into the
four-float rotation node in VRML.

The vector is a one-unit vector indicating a 3d point one unit from
the origin.

The four-float rotation node gives an axis (a 3d vector) followed by
an angle of rotation around that vector.

Thanks,

Dave Coventry


Post Follow-Up to this message ]
Re: 3d rotational vector to 4-float VRML rotation node
 

Herbert Stocker




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  

Dave Coventry wrote:
quote:
> Hi, > > I need help in translating a vector rotation element into the > four-float rotation node in VRML. > > The vector is a one-unit vector indicating a 3d point one unit from > the origin.
Please tell me how this vector describes a rotation, then i can (probably) tell you how to calculate the SFRotation. But let me guess: Does the vector describe where the user should look at? In this case try ori= new SFRotation(new SFVec3f(0, 0, -1), yourVector); In general, the constructor new SFRotation(vectorA, vectorB) calculates an SFRotation that rotates vectorA into vectorB, and 0 0 -1 is the direction a user looks into by default. (Excatly this constructor calculates the shortest rotation from A to B.)
quote:
> > The four-float rotation node gives an axis (a 3d vector) followed by > an angle of rotation around that vector. > > Thanks, > > Dave Coventry
-- Herbert Stocker (aka hersto) http://www.hersto.de www.bitmanagement.de


Post Follow-Up to this message ]
Re: 3d rotational vector to 4-float VRML rotation node
 

Dave Coventry




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  
Herbert,

Thanks very much for your reply,
quote:
> Please tell me how this vector describes a rotation, then i can > (probably) tell you how to calculate the SFRotation. > > But let me guess: Does the vector describe where the user should > look at?
Yes the vector describes the direction vector from the origin.
quote:
> In this case try > ori= new SFRotation(new SFVec3f(0, 0, -1), yourVector);
How would this be used? Could you use it like so: Transform{ rotation new SFRotation(new SFVec3f(0, 0, -1), (-0.99863, -0.052336, 1.67112e-005)) children[....] }
quote:
> In general, the constructor new SFRotation(vectorA, vectorB) > calculates an SFRotation that rotates vectorA into vectorB, > and 0 0 -1 is the direction a user looks into by default. > (Excatly this constructor calculates the shortest rotation > from A to B.) >


Post Follow-Up to this message ]
Re: 3d rotational vector to 4-float VRML rotation node
 

Herbert Stocker




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  

Dave Coventry wrote:
quote:
> Herbert, > > Thanks very much for your reply, > > > > Yes the vector describes the direction vector from the origin. > > > > > How would this be used? Could you use it like so: > Transform{ > rotation new SFRotation(new SFVec3f(0, 0, -1), (-0.99863, > -0.052336, 1.67112e-005)) > children[....] > } >
Would be too easy. ;-) You need to use a Script node, that calculates the rotation and sends it to the Transform. DEF Trans Transform { } DEF Scr Script { field SFVec3f dir 0 1 0 eventIn SFVec3f set_dir eventOut SFRotation ori_changed field SFVec3f negZ 0 0 -1 url "vrmlscript: function initialize() { ori_changed= new SFRotation(negZ, dir); } function set_dir(d) { dir= d; ori_changed= new SFRotation(negZ, dir); } " } ROUTE Scr.ori_changed TO Trans.rotation ROUTE Something.dir_changed TO Scr.set_dir # if required. If the direction vector doesn't change dynamically, you can omit eventIn SFVec3f set_dir and function set_dir(d) Herbert -- Herbert Stocker (aka hersto) http://www.hersto.de www.bitmanagement.de


Post Follow-Up to this message ]
Re: 3d rotational vector to 4-float VRML rotation node
 

Herbert Stocker




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  

I wrote:
quote:
> function set_dir(d) > { > dir= d; > ori_changed= new SFRotation(negZ, dir); > } >
This calculates the shortest rotation from negZ to dir. It might be not sufficient if you want to adjust the Viewpoint or an avatar. The Viewpoint will be tilted sidewards if you have a Y component in dir. Better to combine two rotations, a horizontal one and then a vertical one for the elevation: DEF Trans Transform { } DEF Scr Script { field SFVec3f dir 0 1 0 eventIn SFVec3f set_dir eventOut SFRotation ori_changed field SFVec3f negZ 0 0 -1 url "vrmlscript: function initialize() { set_dir(dir); } function set_dir(d) { dir= d; var dirH= new SFVec3f(dir.x, 0, dir.z); var oriH= new SFRotation(negZ, dirH); var oriV= new SFRotation(dirH, dir); ori_changed= oriH.multiply(oriV); // For Cortona you need to swap both operands. // use Browser.getName() for deciding whether // it runs in Cortona or not. } " } ROUTE Scr.ori_changed TO Trans.rotation ROUTE Something.dir_changed TO Scr.set_dir This is not tested, because i don't have a test case. So maybe R. Russel needs to give me back the cigar. :-) Herbert P.S.: dir need not be of length 1. -- Herbert Stocker (aka hersto) http://www.hersto.de www.bitmanagement.de


Post Follow-Up to this message ]
Re: 3d rotational vector to 4-float VRML rotation node
 

Dave Coventry




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  
Herbert,

My problem is that I'm trying extract extruded circles out of an
AutoCAD drawing using lisp (Autolisp).

The circle is decribed by a centre point and a radius which is on a
plane which is described by it's normal (the direction vector).

There is also a value called thickness which, if it exists, describes
the extruded height of the circle.

I'm trying to convert these into a 'Cylinder' primitive, rotated as
described by the direction vector.

The problem with using the technique you advocate is that if there are
a thousand (or more!) such circles, there would need to be a
corresponding number of scripts to rotate each cylinder.

Dave


Post Follow-Up to this message ]
Re: 3d rotational vector to 4-float VRML rotation node
 

Joerg Scheurich aka MUFTI




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  
> The problem with using the technique you advocate is that if there are
quote:
> a thousand (or more!) such circles, there would need to be a > corresponding number of scripts to rotate each cylinder.
You can define a PROTO, that includes both the shape and the script and reuse this PROTO thousands times. so long MUFTI -- Unbekannter Fehler. Der Fehler 999 wurde erkannt. Legen Sie den Datentraeger "C:\" ein, um den Fehler zu beheben. Fortfahren/Fortfahren


Post Follow-Up to this message ]
Re: 3d rotational vector to 4-float VRML rotation node
 

Dave Coventry




quote this post edit post

IP Loged report this post

Old Post  12-04-03 - 06:00 PM  
Herbert,

I though that if I take the dot product of the direction vector and
the (0,0,-1) I would get the vector of the normal of the plane formed
by the direction vector and the default VRML vector.

Then I need the angle between the two vectors which would give me the
fourth float. However, this does not give the expected result....

Dave Coventry


Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 05:09 AM. Post New Thread   
  Previous Last Thread   Next Thread next
VRML archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top