## Get raycast world intersection point?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

### Get raycast world intersection point?

When a ray intersects with a newton body is it possible to get the point (in world coordinates) where it intersected?
meds

Posts: 6
Joined: Sat Dec 20, 2008 7:01 am

### Re: Get raycast world intersection point?

Ofcourse, you take the origin point of the ray and direction normal you gave it when initiating ray, and move the point along the normal for the intresect distance.
Help improving the Newton Game Dynamics WIKI

JernejL

Posts: 1531
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

### Re: Get raycast world intersection point?

Delfi wrote:Ofcourse, you take the origin point of the ray and direction normal you gave it when initiating ray, and move the point along the normal for the intresect distance.

Thanks, I was actually trying to do something similar but after reading your post realized I was actually moving the point along the normal of the origin rather than along the ray direction
meds

Posts: 6
Joined: Sat Dec 20, 2008 7:01 am

### Re: Get raycast world intersection point?

The intersect distance is in normalized [0..1] coordinates, with point0 of the ray cast being 0 and point1 being 1. Therefore, don't move along the normal, but simply interpolate between p0 and p1 of your ray cast using the intersect distance (or intersect parameter as the Newton header calls it). For example:
Code: Select all
`vec3 p0 = origin, p1 = origin + direction * 100;NewtonWorldRayCast(..., &p0.x, &p1.x, ...);onHit(..., intersectParam){    vec3 worldPos = p0 + (p1 - p0) * intersectParam;}`
agi_shi

Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm