Advertisement

Lines Intersecting planes

Started by April 19, 2000 11:03 AM
1 comment, last by Fisk 24 years, 7 months ago
I have two points in 3d space. They lie on opposite sides of a plane. Now, I also have some math stuff in there to calculate the point of intersection along the line formed by the two points and the plane. However, the resulting points dont end up being on the plane in most cases, but they are pretty darn close. All this is because floats dont have infinite precssision (doh! . Does anyone know if there is a way to work around this WITHOUT making the plane "thick"? If the plane is thick, a polygon intersecting the plane that is split in two might change the geometry that it is a part of. Meaning that geometry might not look the same. A cube might no longer actualy be a cube.
=============================="What if Bill Gates hade a penny everytime windows crashed? Oh wait, he does!"-Dont know who said that, but it's funny :)-Joacim Jacobsson
a) use doubles instead of floats to get more precision.

b) You could use an own data format to calculate with rational numbers a/b:

struct rational
{
long a;
unsigned long b;
}


where a contains also the sign (you could also make b signed instead of a).
TRy to divide a and b by a (positive) integer with a % integer == b % integer == 0.
To determine which is the biggest integer you can do this with, use following algorithm (use only the amount of the signed var):

unsigned long BiggestDivisor(unsigned long a, unsigned long b)
{
while (a!=b)
{
if (a>b) a -= b;
else b -= a;
}
return a;
}


If the precision is not high enough, you could use "very big integers" which are described in "Help with HUGE numbers!?!"(General and Game Programming Discussion, last post 16 April) for a and b.

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
Advertisement
... and try to divide a and b by an integer after each operation!

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA

This topic is closed to new replies.

Advertisement