POV-Ray : Newsgroups : povray.binaries.scene-files : quaternions.inc (fixed) Server Time
2 Sep 2024 02:18:21 EDT (-0400)
  quaternions.inc (fixed) (Message 1 to 5 of 5)  
From: None
Subject: quaternions.inc (fixed)
Date: 8 Oct 2003 10:37:44
Message: <Xns940E6C1F42D3FNone@204.213.191.226>
I've fixed quaternions.inc so that you shouldn't get the warnings any 
more.  And I've made changes thanks to Tor Oval Kristenen's suggestions.

I realise that the include was meant almost exclusively for script 
writers , so I added a sample macro for a regular object modifier.  More 
could be made like this taking advantage of quaternions.


    	RotSimulXYZ(Angles)    	// In Degrees!

It will rotate an object along the three axes XYZ using Euler angles 
simultaneously (all at the same time).  So it's like a rotate but it 
doesn't suffer from Gimbal Lock.

ex.:
    	object ( Basketball
    	    	RotSimulXYZ(<90,0,90>)
    	}

I still prefer Radians, myself, since Radians apply direclty to the 
radius of an object and how much it should rotate, but I made it degrees 
here to remain consistent with regular Povray transforms.


Post a reply to this message


Attachments:
Download 'quaternions.inc.txt' (7 KB)

From: Dave Matthews
Subject: Re: quaternions.inc (fixed)
Date: 8 Oct 2003 12:30:01
Message: <web.3f843a4ad22575a210dd5cfd0@news.povray.org>
Alain,

Thanks for this inc.  Not only should it prove useful in itself, but I'll be
talking about quaternions (briefly) in my multivariable Calculus class, and
I'll share this with my students (if you don't mind) as a good
demonstration of some of their uses.  Sir William Rowan Hamilton would be
proud.

BTW, Hamilton provides me with my favorite quote I use in college algebra
(the uniquely American way of terming what should be remedial algebra --
worse yet, the prerequisite for "college" algebra at this school is called
"higher algebra;" higher than what, I'm not sure.)

Hamilton, from his "Theory of Conjugate Functions" (1837):

"[I]t requires no particular scepticism to doubt, or even to disbelieve, the
doctrine of Negatives and Imaginaries, when set forth (as it has commonly
been) with principles like these:  that a greater magnitude may be
subtracted from a less, and that the remainder is less than nothing; that
two negative numbers, or numbers denoting magnitudes each less than
nothing, may be multiplied, the one by the other, and that the product will
be a positive number, or a number denoting a magnitude greater than
nothing; and that although the square of a number, or the product obtained
by multiplying that number by itself, is therefore always positive, whether
the number be positive or negative, yet that numbers, called Imaginary, can
be found or conceived or determined, and operated on by all the rules of
positive and negative numbers, as if they were subject to those rules,
although they have negative squares, and mut therefore be supposed to be
themselves neither positive or negative, nor yet null numbers, so that the
magnitudes which they are supposed to denote can neither be greater than
nothing, nor less than nothing, nor even equal to nothing.  It must be hard
to found a science on such grounds as these."

Dave Matthews


Post a reply to this message

From: None
Subject: Re: quaternions.inc (fixed)
Date: 8 Oct 2003 14:24:18
Message: <Xns940E9287FA9EFNone@204.213.191.226>
"Dave Matthews" <dma### [at] wrmnwestmnscuedu> wrote in
news:web.3f843a4ad22575a210dd5cfd0@news.povray.org: 

> Alain,
> 
> Thanks for this inc.  Not only should it prove useful in itself, but
> [...]

Thanks for your words Dave.  I can only hope that it is useful to someone.  
Please feel free to do anything you wish with the file or it's contents.


Post a reply to this message

From: None
Subject: Re: quaternions.inc (fixed)
Date: 8 Oct 2003 18:24:25
Message: <Xns940EBB3DAFE5DNone@204.213.191.226>
As has been pointed out by Tor Olav Kristensen, line 176 of quaternons.inc 
should read:

  <AT*Q.x,AT*Q.y,AT*Q.z,0.5*ln(Qsc(Q))>

("log" should actually be "ln".)

This is located in the Qln() macro, and was used by the interpolation 
macros only.  I'll wait before posting an update until I've tested 
everything more thouroughly and/or brought more enhancements.


Post a reply to this message

From: None
Subject: Re: quaternions.inc (fixed)
Date: 10 Oct 2003 17:48:07
Message: <Xns9410B51A87EFANone@204.213.191.226>
Another note:  someone mentionned to me that an orientation they were 
incrementing might not be working.

It's important to keep in mind that (quoted from my Calculus book, which, 
by the way, only barely mentions quaternions): "quaternions do not obey the 
commutative law (that is, A * B != B * A); this was the first algebra in 
which such behavior was studied."

So the order of multiplication is important.

Basically, if you have an orientation qO and you want to increment it with 
the orientation qI, you will want to multiply them like this:

    	#declare q0 = QMultiply(qI,qO);

That will work, the other way around might yield unexpected results.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.