[Closed] Geometrical calculations : points, lines, planes : intersections, distances, angles
Hey people, lovely math here heheh i’v forgotten most of it heheh.
I’m trying now to get the angle between 2 points.
So i looked in the reference. there it says the following :
to calculate the angle use the following formula :
theAngle = acos(dot (normalize v1) (normalize v2))
So i tried this in max. if i select 0.0.0 and 150.661,150.661,0 i get 45. till now all okey.
But if i select [size=2]10,10,0 and 150.661,150.661,0 i get 0.0197823[/size]
[size=2][/size]
[size=2]Hmmmmm why?[/size]
[size=2]for both two the angle should be 45. but i get different results.
Any1 who can shed some light on this ?[/size]
[size=2][/size]
[size=2]Many thx in advance![/size]
[size=2][/size]
Very strange to get [size=2]0.0197823, you should get 0 since the vectors are pointing in the same direction(the angle between them is 0 ). Maybe its a float point accuracy problem at the normalization(1 inversion, 3 multiplies and one square root) and the acos. But anyway, the formula is correct.
[/size]
The normalize function returns a unit vector, meaning that it’s length equals 1 unit. Normalizing [0,0,0] will return [1,0,0], so this explains why the result of your first example is 45. Your second example should return 0, but returns 0.0197823 instead because of round-off errors.
1. [0,0,0] [150.661,150.661,0]
== [1,0,0] [0.707107,0.707107,0] (normalized)
== 45
2. [10,10,0] [150.661,150.661,0]
== [0.707107,0.707107,0] [0.707107,0.707107,0] (normalized)
== 0
Hope this helps,
Martijn
Nice thread!
Any idea in how to test if a point is inside a n-dimensional polyhedron just by coordinates? If one has all the vertexes coordinates of a 3d solid and a point3, how to check if the point3 is inside?
cheers
I don’t have the complete solution but some ideas:
First try a fast test : find if the point is completely outside the volume by using the distance.
For example: you find the center of the bounding box of the volume and the point which is farthest. If your point is farther then it is not inside the volume. It’s obvious but that avoid to apply a complex function each time…
After… I’m not sure that is 100% secure but if you use the normal of the faces I think we can have a good approach to do that.
For a convex volume, a point is inside a volume if this point is behind of each face of the volume.
For each face:
- find the vector of the point-plane projection of the face
- calculate if the vector have the same direction than the normal of the face
- if all vectors have the same direction then your point is inside the convex volume
The problem appears when you have a non-convex volume.
For example imagine a form like a “U” (in 3D)
If your point is at the center of the U, ok that does work because the point is really outside the volume in itself.
… but if the point is inside of the volume then there are several faces where the normal is in opposite direction of the vector of the point-plane projection.
Probably the solution is to divide the concave volume in several convex volumes. After you test for each convex volume if the point is inside or not and you stop as soon as you find a point inside…
I had another idea.
If the point is inside the volume, you can trace a ray to any direction and you intersect a face.
You compare the 2 vectors (your ray and the face normal) and if the sign of the dot product is positive then your point is inside the volume. And that could work for a concave volume
hello,
nice one with the geometry, and thanks for starting such a thread,does anyone know how to find the intersection of a plane(or a cube, or polyhedra) and a spline?
Hello,
I had sent a question rather similar about splines but it seems that it is not possible to find a mathematical solution for a spline and the only solution is to convert your spline into on a certain number of lines or walking the spline with iterations.
Here is the thread:
http://forums.cgsociety.org/showthread.php?f=98&t=470089&page=5&pp=15
But if somebody can confirm this…
hi arketip,
i also looked for the same thing for a long time –
as you say the only thing i found was subdividing by n interations and getting closest to one of these
i dont think you can do any other way
I have another question.
In this thread there is a solution for finding the intersection between a plane and a line. But do you know what is the best calculation for triangle intersection ?
I can calculate the intersection of the triangle plane and after calculate if this point is inside the triangle. I would like to find an optimized solution. Maybe with the dot product ?