Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Promit

Volume Integration: Solids of Rotation

This topic is 5988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Now don''t tell me how to integrate for volumes. I already know how! I wasn''t sure whether this would go better in Graphics Programming and Theory or here, but oh well. I want to make a simple app that would allow me to basically visualize solids of revolution. I can do so in my mind, far better than most people in fact. Only problem is, it takes a lot of thinking and tires me out sometimes. But back to the problem: I want to create a solid of revolution given a certain graph. I don''t need to deal with equation parsing really; it''s the graphical/mathematical concept that intrigues me. Let''s say I have simple graph sort of thingy in a 3D app that I can move around. I''ll avoid how I actually represent this curve unless it is important. Let''s jsut say I have a mesh with vertices. Say that at any value X I know a value Y and that there is no Z axis to be considered with the graph itself. Now, I want to rotate this graph around the Y axis to come up with a solid of revolution. Basically, the effect I want is about what 3DS MAX''s "Lathe" command gives you. How would I go about doing this? I''m pretty clueless as to what to do... ----------------------------- Direct3D vs. OpenGL The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence. Democracy is where you say what you want and do what you''re told.

Share this post


Link to post
Share on other sites
Advertisement
You wouldn''t start with a mesh. Rather you would start with a series of points. The 1st and 2nd, 2nd and 3rd, 3rd and 4th and so forth form line segments. You are going to convert that to a triangle strip. A triangle strip is a series of points forming triangles instead of line segments. The triangles are formed by the 1st, 2nd and 3rd points, 2nd, 3rd and 4th points and so forth. The easiest would be to have two sets of points. Starting out that would be your original points and each of the points rotated around your axis of rotation. So say your original points are pn and the rotated points are pn''. Your triangle strip is p1, p1'', p2, p2'', p3, p3'', etc.

Triangles are guaranteed to be coplanar. Quads are not. It seems like quads resulting from a surface or rotation should be coplanar. I don''t feel up to proving that though. If they are then you can use quad strips instead. A quad strip forms polygons from four successive points so your quad strip would be p1, p1'', p2'', p2, p3, p3'', p4'', p4, etc.

Now if it is the actual rotation you are unsure of then I suggest you look at some of the Articles on tranform matrices under "Articles and Resources". If all you are doing is a rotation around a single coordinate axis you don''t really need matrices. Rather you can just use the angle addition formulas for sin and cos. Basically you view x=r*cos(t) and y=r*sin(t). Your rotated point is x''=r*cos(t+dt) and y''=r*sin(t+dt), but the angle addition formulas tell you that cos(t+dt) = cos(t)*cos(dt)-sin(t)*sin(dt) and sin(t+dt) = sin(t)*cos(dt)+sin(t)*cos(dt). So x''=r*cos(t)*cos(dt)-r*sin(t)*sin(dt) and y''=r*cos(t)*sin(dt)+r*sin(t)*cos(dt), but since x=r*cos(t) and y=r*sin(t) x''=x*cos(dt)-y*sin(dt) and y=x*sin(dt)+y*cos(dt). That is a rotation around the z axis, but you can switch z with y for a rotation around the y axis or z with x for a rotation around the x axis.

Share this post


Link to post
Share on other sites
If all you want is a lathe type effect, how about creating a function that encloses a circle around the z axis with the original function as the radius:

let f(x) be a function of x
let g(y) be a function of y that for any constant a, g(a) is a circle whose radius is f(a), and whose center is (0,0,0)

Then by the general equation for a circle centered at the origin: x^2+y^2=r^2 where r is the radius.
By the definitions we''ve given, x^2+y^2=g(f(x))^2

Tesselate into polys by simply taking arbitrary values of x and y and calculating z(which is g(x)). Simply take the sin and cos of an angle that is some fraction of pi/2, multiply by x and f(x) respectively, square each, and find their (positive) square root. Reflect appropriately to find the whole solid''s surface.

Share this post


Link to post
Share on other sites
I can calculate Z values on a given angle of rotation quite easily. So basically, I would choose a level of tesselation and then synthesize a triangle strip from a line strip?

-----------------------------
Direct3D vs. OpenGL
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Democracy is where you say what you want and do what you''re told.

Share this post


Link to post
Share on other sites
It''s provable, I think, that given points A, B, C & D, where A & B lie on a line parallel to a line the contains C & D, that points A, B, C & D are coplanar, but geometry is not my strong point. If I had a good reference book, I''d probably prove it for the fun of it, but I don''t, so I won''t.

But if that conjecture is true, just choose two points with the same angle around the z axis and two points with a different angle, and you can use those four points as the corners of at least a parallelogram, probably a rectangle(too lazy to think about this further)

The alternative is to use some facility resident in your API to graph curves directly, but translation to that system would not be fun.

Share this post


Link to post
Share on other sites
quote:
Original post by Flarelocke
It's provable, I think, that given points A, B, C & D, where A & B lie on a line parallel to a line the contains C & D, that points A, B, C & D are coplanar


This is not strictly the case. It is possible that AB never intersects CD but that A,B,C & D are not coplanar. Consider two arbitrary lines in 3-space. It is fairly trivial to find two non-intersecting lines that do not lie in the same plane. The result you mention generally follows from the usual definition of parallel lines: two lines that are coplanar and never intersect. Non-intersection is not a sufficient test for parallel lines.

However, it IS true that any two lines that intersect are coplanar!

Timkin



Edited by - Timkin on February 27, 2002 11:50:24 PM

Share this post


Link to post
Share on other sites
If I follow what you are saying that isn''t what he is saying. The fact that the lines are parallel comes from how the points are generated. You are forming a quad by taking two points in the xy plane and rotating them around the y-axis by the same angle. That gives you two lines that may or may not be parallel and two that definitely are parallel. Formal proofs are not a strong suite for me, but I think you can see that will be true.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!