Collision Ray from 2 points

Hi everyone!

I’ve come up with a little issue during my development with panda.
I want to generate a CollisionRay from two given points (That is, one is
the origin and the other one determinates the direction).

I read from reference that the last three parameters for a CollisionRay are
dy,dx and dz. How can I generate a vector for this from two given points?

I’ve never dealt with 3D vectors so far, so I’m not sure on what to do.

Thanks in advance!

Unless I’m missing something, you should just be able to use the vector. Fundamentally a vector contains the same numbers as a point, but the interpretation is that a vector represents a triple of distances from a point (in this case the collision model origin) rather than coordinates in absolute space. If you can generate the vector (point_B - point_A) you should absolutely be able to use its x/y/z explicitly, and Panda may even let you just pass the whole Vec3 in as an argument.

A vector is the difference between two points. If you subtract a Point3 and a Point3, the result is a Vec3, and this is indeed accepted by the CollisionRay constructor.


start_point = Point3() #start of the ray
other_point = Point3() #some other point on the ray

vector = other_point - start_point
vector.normalize() #just in case

ray = CollisionRay()