Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Side of the Plane  (Read 1326 times)
0 Members and 1 Guest are viewing this topic.
Offline abies

Senior Member





« Posted 2003-12-07 18:24:22 »

Let's suppose that we have a plane Ax + By + Cz + D = 0. It's normal is (A,B,C). Which side do we assume to be 'inside' halfspace given by this plane ? Points which are on the side pointed by the normal (distance to plane is positive) or points on the other side of normal (distance to plane[1] is negative) ?
At first it was natural for me that points with positive distance (pointed to by normal) are 'inside'. But then I started to wonder - if you look at the plane as part of mesh, 'inside' of mesh is probably in opposite direction to normal...

My question for 'wise heads' here: Which way I should use for all computations ? For a point to be between number of planes, should it's distance[1] from every one be negative or positive ?


[1] distance = Ax+By+Cx+D for point (x,y,z)

Artur Biesiadowski
Offline Daath

Junior Member




Java games rock!


« Reply #1 - Posted 2003-12-07 20:26:23 »

There is no definitive answer to that. It really depends on what you are trying to achieve. I can easily picture two scenarios which will need positive and negative normals.
 1. positive - Wanna use plane to "see' what is inside space enclosed by planes (since you mentiones halh-space case)
 2 negative - say lighting normals for box from outside
  
 This is case dependent scenario .
Offline DavidYazel

Junior Member




Java games rock!


« Reply #2 - Posted 2003-12-07 22:15:12 »

If you make this change then please refactor the polygon clipping code, it was a bitch to get working and depends on the halfspaces as they currently work.

David Yazel
Xith3D Project Founder
http://xith3d.dev.java.net

It may look complicated, but in the end it is just a bunch of triangles
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #3 - Posted 2003-12-08 05:07:13 »

OpenGL has a function that deals with planes and halfspaces - glClipPlane(...). Description of this function says:

Quote
If the dot product of the eye coordinates of a vertex with the stored plane equation components is positive or zero, the vertex is in with respect to that clipping plane. Otherwise, it is out.


Here is a description from http://wwwcsif.cs.ucdavis.edu/~jankunm/175/WOGL_clipping_functions.html:

Quote
Clipping Planes
A clipping plane divides space into two, half on one side of the plane, half on the other. The plane has a front and a back side, the front side is the one with the plane's normal vector. So space gets divided into a front halfspace and a back halfspace. Let's define "inside" to mean something is in the front halfspace. In 3D space, the one we're used to, a plane is defined by this plane equation.
   Ax + By + Cz + D = 0
We can store the plane coefficients in a vector (A,B,C,D). To determine whether or not a point is inside the front halfspace of a plane, we find the distance from the point (xo, yo, zo) to the plane (A,B,C,D).
   distance = Axo + Byo + Czo + D
If the distance is positive, the point is in the front halfspace, inside. If the distance is zero, the point lies on the plane. If the distance is negative, the points lies in the back halfspace, outside.

In 4D homogeneous space, planes are specified by equations of this form.
   Px + Qy + Rz + Sw = 0
Again, we can store the plane coefficients as vectors (P,Q,R,S). To see if a point (xo, yo, zo, wo) is in the front halfspace, on the plane, or in the back halfspace, we take the dot product of the point and the plane's coefficient vector. This number isn't really a distance, but at times it might help to think of it as such.
   dot product = Pxo + Qyo + Rzo + Swo
Again, inside is > 0, on the plane = 0, outside is < 0.


I think we should choose definition of In/Out from OpenGL specs just to aboid one more difference and be able to point peolpe to OpenGL docs.

Yuri

Yuri Vl. Gushchin
JProof Group
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (16 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (34 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (20 views)
2014-08-16 06:20:21

Tekkerue (31 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (44 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!