Results 21 to 30 of 74
Thread: Need some geometry help
-
12-04-2014, 01:05 PM #21
I wasn't able to leverage what you had... So I started with a blank screen in OpenScad.
It turns out, you don't need a Cray Super Computer to do this. I just made 3 different toriods. I made the generic one with n1=1 and n2=1. And then I made a couple more just to make sure the code worked:
Toriod.jpg
UPDATE: Those equations might be flawed. Some of the possible toroids only generate 1 quadrant of the shape. For example, n1=2 and n2=1. You get the correct shape, but only 1/4 of the toroid. I think some of these toroid shapes are imaginary. The reason is this: You can't take a fractional power of a negative number. But X is defined by X= cos^n1(theta)*(r0+r1*cos^n2(phi)) The cosine function goes negative as theta and phi sweep through the circle. So some of the coordinates generated by the equations are meaningless. (You are not allowed to raise a negative number to a fractional power --- that is undefined)
FURTHER UPDATE: The equations are wrong. Any time n1 or n2 is an even number, you are squaring the sin() and cos() functions. This causes any negative number they produce into a positive number. There is no way to generate points in the negative quadrants if you have n1^2 or n2^2 positive. n1 & n2 can only be 1,3,5,7,etc.Last edited by Roxy; 12-04-2014 at 06:09 PM.
-
12-04-2014, 04:03 PM #22
OK... I'm done with Toroids for now... Here is an updated screen shot with various odd numbers for n1 & n2. Note that the 'round' toroid in the upper right is not a generic toroid. Its edges are curved kind of funny. But, you probably don't want that one anyway, because it is going to waste a lot of space in the doughnut box when you make donuts that shape.
Toriod.jpg
You might want to bump the resolution up to examine some of the shapes. Especially ones like the center one. But if you do that, you might want to comment out the generation of the other toroid's because this gets very expensive computationally (but still no need to run out and buy a Cray Super Computer!). You can do that by changing the:
for (theta = [0:18:360])
for (phi = [0:18:360])
to what ever you can tolerate. Maybe something like:
for (theta = [0:6:360])
for (phi = [0:6:360])
and by changing all the +18's to +6 in the hull() directive:
Toriod.jpg
And of course... If that is too 'thin' for all the doughnut eater's that are policing Australia, you can mess with the value for r1 so they only need one instead of the usual 2 or 3 doughnuts per session!Last edited by Roxy; 12-04-2014 at 05:48 PM.
-
12-04-2014, 06:06 PM #23
- Join Date
- Jun 2014
- Location
- Burnley, UK
- Posts
- 1,662
You are right. I only used mine in the first quadrant as it took too long. The shape needs translating wholly into the first quadrant before it is made in order to stop imaginary number problems.
-
12-04-2014, 06:16 PM #24
Just as an FYI: I generated tiny cube's as my points. Spheres are much more natural. But computationally, it takes way more to generate them, and it takes a lot more work to put a hull around them. I haven't done it, but I suspect it would take 10x as long to run this same code with sphere() in the generate_point() module.
-
12-04-2014, 07:45 PM #25
Just a wild comment, but to eliminate the "Any time n1 or n2 is an even number, you are squaring the sin() and cos() functions. This causes any negative number they produce into a positive number. There is no way to generate points in the negative quadrants if you have n1^2 or n2^2 positive." problem what would happen if you made the computation use the ABS value?
I must refer you back to the original source: http://paulbourke.net/geometry/torus/
It shows the results of n1 and n2 being a positive number. n1 controls the shape of the body. If n1 = 2, then the shape is squared up. n2 controls the shape of the cross section.
OME
-
12-04-2014, 08:00 PM #26
Last edited by Roxy; 12-04-2014 at 11:15 PM.
-
12-04-2014, 11:10 PM #27
What would happen if, instead of having the Origin at (0,0,0), which results in sin and cos being -ve in certain segments, you translate the centre of the object to (r0, r0 , r1 ) so that X, Y and Z are always positive?
Alternatively, and probably the best way is to do the cheat that Roxy proposed:
1. Restrict the ranges of theta and phi to between 0 an pi.
2. Do three translations to put this quarter into the other three quadrants.
3. Consecrate the Union.
OME
-
12-05-2014, 12:58 AM #28
I would love to hear a detailed analysis of this transformation by a resident Math Major. But my guess (just off the top of my head) is this doesn't work. Those equations are written using a spherical (3D Polar) coordinate system that produce a mapping into the Cartesian coordinate system. I would expect shifting its center isn't going to change the fact the equations lose the sign of cos() & sin() function when even powers are used for n1 and n2.
This is an example of where the OpenJScad language shines. From a computational perspective, only one quadrant of information would have to be generated (and be saved as a variable) and then it could be mirrored 3 times to fill out the entire solid.
Maybe Dacb would know enough to convert the existing or next Toriod.scad to a J-Scad file? That would be interesting to see. Especially since J-Scad has cleaned up the syntax of the language so much.
The way I understand it, we are dealing with both sin^2() and cos^2() functions losing the negative values. And we have all combinations of sin^n1() and cos^n1() and sin^n2() and cos^n2() of both theta and phi. The only place both of those functions are always positive is in the first quadrant. So we need to restrict theta to values of 0 to pi/2. You can not restrict phi to that range because you wont get the complete shape of the toroid. Phi needs to still vary from 0 to pi. What this means is there may still be some limitations on n2 being stuck at positive numbers because you can't be raising cos(phi) (with a negative value) to a fractional power. However, I think n1 is free to be both positive and negative with this technique.
Not translations... mirror() operations. We need to mirror() the positive portion ((x,y,z) all positive) into the other 7 areas. Probably doing the mirror() to the negative z area of the first quadrant makes sense. And then mirroring that to either the 2nd or 4th quadrant would be next to form a 1/2 toroid. And then mirror() that to get the whole thing.
The big problem with doing this in OpenScad is you have to keep regenerating the base information you are going to mirror() even though you already have generated it. OpenJScad doesn't have this limitation.
I would do the mirror() with an ever so slight transformation([,,]) towards the reflection... That way, you will end up with a manifold surface that is fully joined of the two halves. Without this, you might end up with errors in the .STL file.Last edited by Roxy; 12-05-2014 at 08:42 AM.
-
12-05-2014, 03:06 AM #29
OK. Let's put this on hold for the weekend. I've sent an email to Dr Bourke asking for his help.
OME
-
12-05-2014, 08:50 AM #30
I changed the wording up above... I had an error. Specifically, it would be useful to ask Dr. Bourke how he generated that table with fractional values. Because (and here is the updated wording):
So we need to restrict theta to values of 0 to pi/2. You can not restrict phi to that range because you wont get the complete shape of the toroid. Phi needs to still vary from 0 to pi. What this means is there may still be some limitations on n2 being stuck at positive numbers because you can't be raising cos(phi) (with a negative value) to a fractional power. However, I think n1 is free to be both positive and negative with this technique.
partial_toriod.jpg
Here are the square toriod's using the mirror() fake out method
:Square_Toriod.jpgLast edited by Roxy; 12-05-2014 at 09:34 AM.
Kickstarter campaing LEGENDARY...
Today, 08:02 AM in Free Self Promotion