Skip to main content

3D Cohen-Sutherland Clipping Algorithm

2 replies [Last post]
lordflasheart
Offline
Joined: 2006-06-28

Hi,

I've been redirected here from the Sun forums. I'm a distance learner and am taking a module on Computer Graphics whereby I have to provide Java code to twenty questions all of which cannot use inherent classes. The only thing I can use is drawRect in order to draw a pixel :-(

I have answered a question on 2D clipping using Cohen-Sutherland algorithm but I am having real problems trying to extend it to 3D. Here I have to clip a line segment from (x1, y1, z1) to (x2, y2, z2) against a canonical view volume, a cuboid from (-1, -1, 0) to (1, 1, 1). I appreciate that the outcodes have been extended to include front and behind. It is just how to divide the lines up in order to clip.

Any pointers would be welcome.

Thanks in advance.

Chris

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
geoman
Offline
Joined: 2006-06-28

are your lines to be clipped on a plane?
then you can reduce your problem to 2D by doing the clipping on that plane.
thanks

Alessandro Borges

Maybe I'm wrong, but your questions are about Analytic Geometry.
Of course you will find a lot of stuff about it, as well java code, but the best source are books as "Calculus with Analytic Geometry", Louis Leithold, and "Introduction to Computer Graphics",James D. Foley, the #1 3D reference.

For fast code just Google: line plane intersection java

java3d-interest@javadesktop.org escreveu: Hi,

I've been redirected here from the Sun forums. I'm a distance learner and am taking a module on Computer Graphics whereby I have to provide Java code to twenty questions all of which cannot use inherent classes. The only thing I can use is drawRect in order to draw a pixel :-(

I have answered a question on 2D clipping using Cohen-Sutherland algorithm but I am having real problems trying to extend it to 3D. Here I have to clip a line segment from (x1, y1, z1) to (x2, y2, z2) against a canonical view volume, a cuboid from (-1, -1, 0) to (1, 1, 1). I appreciate that the outcodes have been extended to include front and behind. It is just how to divide the lines up in order to clip.

Any pointers would be welcome.

Thanks in advance.

Chris
[Message sent by forum member 'lordflasheart' (lordflasheart)]

http://forums.java.net/jive/thread.jspa?messageID=127899

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

---------------------------------
Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora!
[att1.html]