Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/quaternions|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. == Quaternions Quaternions are an extension to the number system: real numbers may be thought of as points on a line, complex numbers as points in a plane, and quaternion numbers as points in four-dimensional space. Apart from mathematical curiosity, quaternions are useful for specifying rotations in three dimensional space (e.g. [[http://wiki.alioth.net/index.php/Quaternion| in this game]]), and also for image analysis. An introduction to quaternions and this scheme library is available [[http://www.ccs.neu.edu/home/dorai/squat/squat.html|here]]. === Exported Procedures <procedure>(make-rectangular w [x [y z]])</procedure> Constructs a number, complex number, or quaternion number depending on if given 1, 2 or 4 arguments. > (make-rectangular 1) 1 > (make-rectangular 1 2) 1+2i > (make-rectangular 1 2 3 4) 1+2i+3j+4k <procedure>(make-polar mu theta [phi psi])</procedure> An alternative way of defining a quaternion, through the magnitude {{mu}}, the angle {{theta}}, the colatitude {{phi}} and longitude {{psi}}. <procedure>(real-part n)</procedure> Returns the real part of a number. > (real-part (make-rectangular 1 2 3 4)) 1 <procedure>(imag-part n)</procedure> Returns the imaginary part (the {{i}}) of a complex or quaternion number. > (imag-part (make-rectangular 1 2 3 4)) 2 <procedure>(jmag-part n)</procedure> Returns the {{j}} part of a quaternion number. > (jmag-part (make-rectangular 1 2 3 4)) 3 <procedure>(kmag-part n)</procedure> Returns the {{k}} part of a quaternion number. > (kmag-part (make-rectangular 1 2 3 4)) 4 <procedure>(magnitude n)</procedure> The length of {{n}} treated as a vector. <procedure>(angle n)</procedure> See {{make-polar}}. <procedure>(number? n)</procedure> Checks if given argument is any kind of number. > (number? 3) #t > (number? 1+2i) #t > (number? (make-rectangular 1 2 3 4)) #t <procedure>(quaternion? n)</procedure> The same as {{number?}}. <procedure>(= q1 ...)</procedure> Tests for equality of given numbers. <procedure>(+ q1 ...)</procedure> Returns the sum of given numbers. > (+ 3 2+3i (make-rectangular 1 2 3 4)) 6+5i+3j+4k <procedure>(- q1 ...)</procedure> Returns the difference of given numbers, associating to left. <procedure>(* q1 ...)</procedure> Returns the product of given numbers. > (* 2 (make-rectangular 1 2 3 4)) 2+4i+6j+8k <procedure>(/ q1 ...)</procedure> Returns quotient of given numbers, associating to left. <procedure>(exp n)</procedure> Usual {{exp}} function extended to quaternions. <procedure>(log n)</procedure> Usual {{log}} function extended to quaternions. <procedure>(expt m n)</procedure> Usual {{expt}} function extended to quaternions. <procedure>(sqrt n)</procedure> Usual {{sqrt}} function extended to quaternions. <procedure>(sin n)</procedure> Usual {{sin}} function extended to quaternions. <procedure>(cos n)</procedure> Usual {{cos}} function extended to quaternions. <procedure>(tan n)</procedure> Usual {{tan}} function extended to quaternions. <procedure>(asin n)</procedure> Usual {{asin}} function extended to quaternions. <procedure>(acos n)</procedure> Usual {{acos}} function extended to quaternions. <procedure>(atan n)</procedure> Usual {{atan}} function extended to quaternions. <procedure>(atan y x)</procedure> Usual {{atan}} function extended to quaternions. <procedure>(vector-part q)</procedure> Returns the quaternion with its real part set to 0. <procedure>(colatitude q)</procedure> See {{make-polar}}. <procedure>(longitude q)</procedure> See {{make-polar}}. <procedure>(conjugate q)</procedure> Returns quaternion with same real part and sign of {{i}} {{j}} and {{k}} part of {{q}} reversed. > (conjugate (make-rectangular 1 2 3 4)) 1-2i-3j-4k <procedure>(unit-vector q)</procedure> Returns a quaternion in same direction as {{q}} but of unit length; the real part of {{q}} is set to 0. <procedure>(dot-product q1 q2)</procedure> Real parts of {{q1}} and {{q2}} must be 0. The dot product is the negative of the real part of {{q1 x q2}}. <procedure>(cross-product q1 q2)</procedure> Real parts of {{q1}} and {{q2}} must be 0. The cross product is the vector part of {{q1 x q2}}. === Author The original version of this library was created by Dorai Sitaram. This port to chicken scheme is by [[/users/peter-lane|Peter Lane]]. === License GPL version 3.0. === Version History * version 1.0: released.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 6 by 0?