|
JVillella
Guest
|
 |
« on: December 31, 2011, 10:03:37 PM » |
|
Hi everyone. I have been learning about the Mandelbulb for quite some time now using hypercomplex triplex numbers. I wanted to try something new though and switched to quaternions. I have implemented them into my fractal explorer buts I only know how to do quaternion multiplication. I have been stuck rendering "z -> z^n + c" with "n" always being 2. Is there a way to do quaternion exponentiation so I can set "n" to something like 8? I would really appreciate some guidance on this. Thank you  Julian
|
|
|
|
|
Logged
|
|
|
|
|
David Makin
|
 |
« Reply #1 on: December 31, 2011, 10:16:41 PM » |
|
Is there a way to do quaternion exponentiation so I can set "n" to something like 8?
Yes, though the exact method isn't to hand for me at the moment - in fact the really weird thing is that getting powers of quaternions using the log/exp method actually has 2 possible values *if* the power and the log of the value are both more than plain complex (i.e. both have a non-zero 3rd or 4th term) this is because quaternions are not commutative so when getting the power using: exp(power*log(value)) the result is not the same as: exp(log(value)*power) *if* both log(value) and power are not plain complex. After a quick Google, I think this pdf is correct (though I only scanned it *very* briefly) in so far as it shows how they're normally treated: http://www.google.co.uk/url?sa=t&rct=j&q=quaternion+log+exp&source=web&cd=5&ved=0CE0QFjAE&url=http%3A%2F%2Fwww.lce.hut.fi%2F~ssarkka%2Fpub%2Fquat.pdf&ei=53r_TszDM4Pp8QPvlPz6Dg&usg=AFQjCNFXWWscHijx2qr5M1z93rhCPYKN7wAlso I don't think I've ever tried it myself, but surely the same method as is used for the triplexes can be applied to quaternions i.e. raising the power of the magnitude by the power value and scaling the relevant angles by the power value, then recombining ?
|
|
|
|
« Last Edit: December 31, 2011, 10:21:17 PM by David Makin »
|
Logged
|
|
|
|
DarkBeam
Global Moderator
Fractal Senior
     
Posts: 2512
Fragments of the fractal -like the tip of it
|
 |
« Reply #2 on: December 31, 2011, 10:43:33 PM » |
|
It is not necessary to "exponentiate" to get power 8! Just repeat 8 times a 2 term product a b c d ... initially set em to the same values to x y z w then do for i 0 to 7 newa = x*a ... etc ... newb ... until newd. then copy newa in a, newb in b ... and finally next i. after that x = a+cx, y = b+cy ... done  use exponentiation only for do some weird power experiments 
|
|
|
|
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
DarkBeam
Global Moderator
Fractal Senior
     
Posts: 2512
Fragments of the fractal -like the tip of it
|
 |
« Reply #3 on: December 31, 2011, 10:47:12 PM » |
|
Ah ... there is a quatpow formula for mandelbulb but nobody uses it (too slow) so ... 
|
|
|
|
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
|
JVillella
Guest
|
 |
« Reply #4 on: January 01, 2012, 03:48:19 PM » |
|
Hi everyone. Thank you for your quick replies. Yes, though the exact method isn't to hand for me at the moment - in fact the really weird thing is that getting powers of quaternions using the log/exp method actually has 2 possible values *if* the power and the log of the value are both more than plain complex (i.e. both have a non-zero 3rd or 4th term) this is because quaternions are not commutative so when getting the power using:
exp(power*log(value))
the result is not the same as:
exp(log(value)*power)
*if* both log(value) and power are not plain complex. I will give this a shot right away! Thanks for the link and the little caveat. It is not necessary to "exponentiate" to get power 8! Just repeat 8 times a 2 term product This is what I have essentially been doing. Do you think I would get different results in any way if I did it using exponentiation?
|
|
|
|
|
Logged
|
|
|
|
fractower
Iterator

Posts: 173
|
 |
« Reply #5 on: January 01, 2012, 04:26:00 PM » |
|
As long as the exponent is a non-negative integer there is a method goes as log2 the exponent.
quad exp_int(quad q, exp e){ int tmp_e = e; quad result = (1,0,0,0); quad q2 = q;
while(tmp_e){ if(tmp_e&1){ result = result * q2; } q2 = q2 * q2; tmp_e>>1; } return(result); }
The trick is that each bit position in e "adds" a unique power of 2 factor of q to the final product. If you know the exponent in advance it is better to unroll the loop and avoid the mispredicted branches. For example a power of 8 would be:
q2 = q *q q4 = q2*q2 q8 = q4 * q4
|
|
|
|
|
Logged
|
|
|
|
DarkBeam
Global Moderator
Fractal Senior
     
Posts: 2512
Fragments of the fractal -like the tip of it
|
 |
« Reply #6 on: January 01, 2012, 04:28:25 PM » |
|
It is not necessary to "exponentiate" to get power 8! Just repeat 8 times a 2 term product This is what I have essentially been doing. Do you think I would get different results in any way if I did it using exponentiation? Impossible, unless you do mistakes in coding. So check all accurately again and again! ...  That's what I do all the times
|
|
|
|
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
|
David Makin
|
 |
« Reply #7 on: January 02, 2012, 12:37:55 AM » |
|
This is what I have essentially been doing. Do you think I would get different results in any way if I did it using exponentiation?
Essentially I think all bets are off *if* both the power and the value are truly quaternionic i.e. both have non-zero 3rd and 4th components, but I think if the value is truly quaternionic but the power is plain real or complex then there's no issue - I'm not so sure if the power is quaternionic but the value is plain real or complex.
|
|
|
|
|
Logged
|
|
|
|
|
JVillella
Guest
|
 |
« Reply #8 on: January 02, 2012, 03:42:44 AM » |
|
I have been experimenting with different exponents and I notice that a power-8 mandelbulb is not visible whilst using a quaternion number system. On your mandelbulb implementations have you noticed this? It is possible I am doing things wrong. I just want to make sure it isn't "normal" before I begin debugging. Thanks, Julian 
|
|
|
|
|
Logged
|
|
|
|
|
David Makin
|
 |
« Reply #9 on: January 03, 2012, 10:30:39 AM » |
|
I have been experimenting with different exponents and I notice that a power-8 mandelbulb is not visible whilst using a quaternion number system. On your mandelbulb implementations have you noticed this? It is possible I am doing things wrong. I just want to make sure it isn't "normal" before I begin debugging. Thanks, Julian  Now I don't follow, AFAIK no-one is mixing quaternions and the Mandelbulb triplex math, except in hybrids.
|
|
|
|
|
Logged
|
|
|
|
|
Syntopia
|
 |
« Reply #10 on: January 03, 2012, 10:50:26 PM » |
|
I have been experimenting with different exponents and I notice that a power-8 mandelbulb is not visible whilst using a quaternion number system. On your mandelbulb implementations have you noticed this? It is possible I am doing things wrong. I just want to make sure it isn't "normal" before I begin debugging. Thanks, Julian  Now I don't follow, AFAIK no-one is mixing quaternions and the Mandelbulb triplex math, except in hybrids. If you mean to create a power-8 Quaternion Julia set, it is possible. It is not related to the Mandelbulb, though. How do you draw your Quaternion systems? Here is an example distance estimator for a power-8 quaternion system, sliced through w=0: vec4 qMul(vec4 a, vec4 b) { return vec4( a.x*b.x - a.y*b.y - a.z*b.z - a.w*b.w, a.x*b.y + a.y*b.x + a.z*b.w - a.w*b.z, a.x*b.z - a.y*b.w +a.z*b.x + a.w*b.y, a.x*b.w + a.y*b.z - a.z*b.y + a.w*b.x ); }
// power 8 vec4 q8(vec4 a) { a = qMul(a,a); a = qMul(a,a); a = qMul(a,a); return a; }
// power 7 vec4 q7(vec4 a) { vec4 a2 = qMul(a,a); vec4 a4 = qMul(a2,a2); return qMul(qMul(a2,a4),a); }
float DE(vec3 pos) { vec4 p = vec4(pos, 0.0); vec4 dp = vec4(1.0, 0.0,0.0,0.0); for (int i = 0; i < Iterations; i++) { dp = 8.0*qMul(q7(p),dp); p = q8(p) + C; float p2 = dot(p,p); if (p2 > Threshold) break; } float r = length(p); return 0.5 * r * log(r) / length(dp); }
Here is an image - it looks even more whipped than the standard power-2 :-)
|
|
|
|
|
DarkBeam
Global Moderator
Fractal Senior
     
Posts: 2512
Fragments of the fractal -like the tip of it
|
 |
« Reply #11 on: January 03, 2012, 11:55:49 PM » |
|
What a waste, to calculate separately pow7 and pow8! 
|
|
|
|
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
|