We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › 3D oval or 3D lens help
Page Index Toggle Pages: 1
3D oval or 3D lens help (Read 863 times)
3D oval or 3D lens help
Mar 30th, 2009, 8:14am
 
Hi Guys,

As part of my project in college, I need to have a 3D beam of light go through a lens and refract. I have the beam working fine. I have hit a hurdle with the 3D thin lens.
I am quite new to processing and from my research there is no built in primitive that will allow me to draw what I need.
Can Sphere() be adjusted to give me a compressed or flatened like shape that will look like a lens.

Any help here guys would be great.
Re: 3D oval or 3D lens help
Reply #1 - Mar 30th, 2009, 9:06am
 
I haven't tried yet the 3D side of Processing, but I guess you can indeed use sphere() (little s) with scaling.
Re: 3D oval or 3D lens help
Reply #2 - Mar 30th, 2009, 10:22am
 
A squashed sphere will indeed produce lens-like effects, but note that it's a different physical shape than sort of classic lens described by standard optics equations.

Remembering waaaaaay back to my college physics days, the lenses we learned about in that unit were modeled as solid geometry operations involving purely spherical surfaces; e.g. the intersection of two spheres to make a standard convex-convex lens, the disjunction of a couple of spheres with a cylinder to make a concave-concave lens, et cetera.

If you squash a sphere, you'll approximate a true convex-convex lens, but it won't be the same because the degree of curvature will vary smoothly across the face of the lens, from a small value in the middle to a high value at the edges.  With a real lens, the curvature at any point is constant until you get to the sharp edges, where the curvature is mathematically undefined.

I really don't know how you'd draw lenses in this fashion using Processing, but then, I've never done any 3-d stuff in processing.  I do wonder, though, whether you might be better off with a different tool like POVRay or something, which not only has built-in geometry operations like union and difference, but is also pretty good at modeling light propagation.
Re: 3D oval or 3D lens help
Reply #3 - Mar 31st, 2009, 5:30am
 
Unfortunately, now would not be the time to change my development environment. I am using an embedded PApplet within AWT GUI. My project is due in 3 weeks! Sad

Thanks guys for you help, I think squashing the sphere would be cheating. There has to be a way of doing it.

Once the object shape looks like a lens, I'm not really bothered. Its really a visual facade, All the equations do the hard work in the background.

Thanks Guys
Re: 3D oval or 3D lens help
Reply #4 - Mar 31st, 2009, 5:46am
 
Perhaps a simple arc?

Code:

strokeWeight(20);
arc(50, 55, 50, 50, 0, PI/2);
Re: 3D oval or 3D lens help
Reply #5 - Mar 31st, 2009, 6:05am
 
A 3D arc? Smiley
Re: 3D oval or 3D lens help
Reply #6 - Mar 31st, 2009, 10:47am
 
Oh, well if you're using the right lens math in the background, then who cares if the visualization is just an approximation of a true lens shape?  I mean, the light rays are still going to bend the correct amounts and directions (assuming you get your math right).

That being the case, I'd totally go with a squashed sphere for now because that will be fast and easy.  Use it as a placeholder, and if you finish the rest of the project (the important pieces of functionality, that is) with some time left over, you can dig into drawing a real lens shape.
Page Index Toggle Pages: 1