|
|
I'm doing a segmentIntersect, now I want to know the angle at which the angle took place.
|
|
|
|
A segment intersection will return to you a normal vector. Normalize the line segment you used to check for segment intersection, and then do a dot product between your normalized vector and the normal vector you got as a result of the intersection. Then
you use acos to change your dotproduct to an angle (in radians).
Vector3 ray = new Vector3(0f, 0f, 0f);
float dist;
CollisionSkin skin;
Vector3 pos, normal;
ImmovableSkinPredicate pred = new ImmovableSkinPredicate();
Segment seg = new Segment(ray, Vector3.Down * 1000.0f)
world.CollisionSystem.SegmentIntersect(out dist, out skin, out pos, out normal, seg, pred);
// Get the segment you made as a vector Vector3 segmentVector = ray + (Vector3.Down * 1000.0f); segmentVector.Normalize();
float dotProduct = segmentVector.Dot(normal); float angle = (float)Math.Acos(dotProduct);
|
|
|
|
Hi,
tanks for the response, but it wasn't needed any more (the thread was created over a year ago)
|
|
|
|
furrie wrote:
Hi,
tanks for the response, but it wasn't needed any more (the thread was created over a year ago)
I figured as much, it was more for anyone else that came across the forums with a similar question.
|
|