|
Kali
|
 |
« on: February 21, 2012, 05:40:20 AM » |
|
Hello everybody I'm trying to develop a new formula, but I need some help because I don't have the time currently to think much about it, so I wanted to ask here to see if I can accelerate the process  In the attached image, let's assume I have the cartesian coordinates for point m. I want to get the angle (a) between the resulting vector and the x-axis, then doubling it and returning the result back to cartesian coordinates. Thanks in advance... Kali
|
|
|
« Last Edit: February 21, 2012, 05:42:43 AM by Kali »
|
Logged
|
|
|
|
|
asimes
|
 |
« Reply #1 on: February 21, 2012, 06:46:06 AM » |
|
Based on the drawing it looks like you are ignoring the y-axis so this is actually a 2D problem (if you look at it as a xz plane). 'a' can be calculated with atan2(z, x). Double the result, and then position the new point with:
float twoa = 2*a; float x = cos(twoa)*radius; // y is unchanged float z = sin(twoa)*radius;
|
|
|
|
|
Logged
|
|
|
|
|
asimes
|
 |
« Reply #2 on: February 21, 2012, 06:52:01 AM » |
|
If I assumed wrong (it looks like the blue arc that represents 'a' only touched the x-axis), then you can use Spherical Coordinates.
To go from Cartesian to Spherical Coordinates: float radius = sqrt(x*x+y*y+z*z); float azimuth = atan2(z, x); float azimuthLength = sqrt(x*x+z*z); float elevation = atan2(azimuthLength, y);
To go from Spherical to Cartesian Coordinates: float x = cos(azimuth)*sin(elevation)*radius; float y = cos(elevation)*radius; float z = sin(azimuth)*sin(elevation)*radius;
|
|
|
|
|
Logged
|
|
|
|
|
Kali
|
 |
« Reply #3 on: February 21, 2012, 07:13:40 AM » |
|
I didn't ignore the y axis! I draw the lines on the x-y plane, below the vector, to help the visualization - and the blue arc touches only the x axis indeed, because I want to find that angle (between the vector and the line that represents the x-axis). The angle I want to find and double, is not perpendicular or aligned to any of the planes defined by the axis, but it's on the plane defined by the x-axis and the vector itself. Is the code in your second post doing this? I'll try to do a better drawing if it's difficult to visualize.
|
|
|
|
|
Logged
|
|
|
|
|
asimes
|
 |
« Reply #4 on: February 21, 2012, 07:26:49 AM » |
|
My second code works (I've used it in a few programs), although when I used it:
X was left to right as default Y was top to bottom as defualt Z was far away to close up as default
So you might have to juggle around x, y, and z, but the equations are not axis specific otherwise (doesn't depend alignment or anything).
|
|
|
|
|
Logged
|
|
|
|
|
Kali
|
 |
« Reply #5 on: February 21, 2012, 07:57:58 AM » |
|
Ok, with that code I get a regular mandelbulb... I doubled the azimuth and elevation angles, but I'm afraid that by doing this I'm not doubling the angle I showed in the picture, but the ones used to get the spherical coordinates, wich is not the same, I think.
|
|
|
|
|
Logged
|
|
|
|
|
asimes
|
 |
« Reply #6 on: February 21, 2012, 03:18:42 PM » |
|
You only should be doubling one of the two angles. Here are some visual helpers (this is what the code is based on) at the top right of the link: http://en.wikipedia.org/wiki/Spherical_coordinate_systemCould you post the code for testing points to make a Mandelbulb? (I'm assuming you are testing the Cartesian Coordinates?) I've been looking around for a tutorial on doing that and haven't had too much luck. I have my own bounding box code for a 3D fractal but it tests the points for a different shape.
|
|
|
|
|
Logged
|
|
|
|
|
Kali
|
 |
« Reply #7 on: February 21, 2012, 04:36:19 PM » |
|
You only should be doubling one of the two angles.
NO!  I used the wikipedia graph to better show what angle I'm talking about. I need to double that specific angle... or in other words, I need to modify (scale) azimuth and elevation angles so "my angle" gets doubled. As you can see, by doubling azimuth and elevation, my angle gets wider than it's double. I have the suspicion that adjusting this could probably lead to a better mandelbulb version. But how to do it?? Could you post the code for testing points to make a Mandelbulb? (I'm assuming you are testing the Cartesian Coordinates?) I've been looking around for a tutorial on doing that and haven't had too much luck. I have my own bounding box code for a 3D fractal but it tests the points for a different shape.
I'm using Syntopia's tool for GPU rendering, Fragmentarium. Are you familiar with it?
|
|
|
|
Logged
|
|
|
|
|
bib
|
 |
« Reply #8 on: February 21, 2012, 04:47:31 PM » |
|
I have the suspicion that adjusting this could probably lead to a better mandelbulb version.
I see what you mean. Good intuition. I'm curious to see how this turns out.
|
|
|
|
|
Logged
|
Between order and disorder reigns a delicious moment. (Paul Valéry)
|
|
|
hobold
Fractal Bachius

Posts: 573
|
 |
« Reply #9 on: February 21, 2012, 06:12:21 PM » |
|
I think this will lead to rotational symmetry around the x axis when used for a generalized Mandelbrot set. That is because:
1. Doubling one angle is inherently a two dimensional operation. (Imagine the doubled angle as the tip of an isosceles triangle. That triangle always lies in the plane which contains both the x axis and the point before doubling.)
2. Vector addition is a linear operation. That means if you add points of a 3 dimensional vector space which all come from a linear subset (i.e. a plane or a line which contains the origin), then the result of the addition will also lie in the same linear subset.
For a Mandelbrot iteration, we always start with z_0 = 0 as the first value (which remains zero when "squared"), then add c, so we always have z_1 = c.
Now z_1 lies in the same plane as c. Doubling the angle of z_1 will not move it out of this plane (the unique plane which contains both the x axis and c, unless c itself lies on the x axis), and neither will adding c. So z_2 will lie in that plane as well. In fact, the complete orbit of any iterated point will be confined to a plane.
In each such plane, we'll get a classical 2D Mandelbrot set, because we are doing geometrically the exact same thing.
|
|
|
|
|
Logged
|
|
|
|
fractower
Iterator

Posts: 173
|
 |
« Reply #10 on: February 21, 2012, 07:25:08 PM » |
|
Taking the vector cross product between the vector M and X will give you the vector you need to rotate about. Once you normalize this vector you can construct a rotation matrix http://en.wikipedia.org/wiki/Rotation_matrix. You can get the angle from magnitude of the cross product (|X cross M| = XM cos(ang)) and (X dot M = XM sin(ang)). Multiplying this matrix by X will give M. Multiplying this matrix by X will give you the double angle result. I used this technique in the generalized box fold that has been integrated into mandelbulber.
|
|
|
|
|
Logged
|
|
|
|
|
asimes
|
 |
« Reply #11 on: February 21, 2012, 08:59:03 PM » |
|
To be honest I don't think I understand what you mean by doubling your angle then. I would assume from the new drawing that it would be doubling both but I guess not, I don't know what then.
I'm not familiar with Fragmentarium, how does it test the points for a Mandelbulb?
|
|
|
|
|
Logged
|
|
|
|
|
Kali
|
 |
« Reply #12 on: February 21, 2012, 10:18:24 PM » |
|
I think this will lead to rotational symmetry around the x axis when used for a generalized Mandelbrot set. ... In each such plane, we'll get a classical 2D Mandelbrot set, because we are doing geometrically the exact same thing.
I see your point, and it's the same I thought at first... but then I was considering that vector adding will lead to different rotational plane at each iteration, wich is not true as you are pointing out. Still want to see the result, I will try fractower method. I'm not familiar with Fragmentarium, how does it test the points for a Mandelbulb?
http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations/
|
|
|
|
|
Logged
|
|
|
|
hobold
Fractal Bachius

Posts: 573
|
 |
« Reply #13 on: February 21, 2012, 11:52:36 PM » |
|
but then I was considering that vector adding will lead to different rotational plane at each iteration, wich is not true as you are pointing out. Still want to see the result, I will try fractower method. This method might still be worth it for Julia sets. I think for those, the orbits would not be confined to planes. Weird situation that the julias might look more interesting than the mandelbrot for that particular construction ... definitely interesting because it would be so unusual. Maybe we can learn something here that helps finding the holy grail.
|
|
|
|
|
Logged
|
|
|
|
|
Kali
|
 |
« Reply #14 on: February 22, 2012, 02:17:35 AM » |
|
This method might still be worth it for Julia sets. I think for those, the orbits would not be confined to planes. Weird situation that the julias might look more interesting than the mandelbrot for that particular construction ... definitely interesting because it would be so unusual. Maybe we can learn something here that helps finding the holy grail.
I was thinking the same! but still can't figure out how to do it... Fragmentarium includes both cross product and rotation matrix functions. For the rotation matrix, I must only setup a variable as type "mat3", assign the matrix to it with the function rotationMatrix3(normalize(RotVector), Angle), then multiply the vector by this matrix. So the RotVector should be the cross product between z and the vector (z.x,0,0), if I got it right. But still I don't understand how to get the angle Should I get the magnitude from the cross product between the vectors z and (z.x,0,0), then use the acos() function to get the angle from this??
|
|
|
|
|
Logged
|
|
|
|
|