1
$\begingroup$

I have an object I wish to cast a ray from, casting using a mathutils direction vector.

The only problem is that I cannot seem to figure out how to find the 3D position (needed for the rayCast function) from the vector.

If anybody could help, I'd be terribly grateful for it. Thanks :)

$\endgroup$
  • $\begingroup$ Do you wish to cast the ray from the objects origin? A specific point on the object? $\endgroup$ – GiantCowFilms May 10 '18 at 17:38
  • $\begingroup$ from the origin, using the vector $\endgroup$ – Cameron Fazakerley May 10 '18 at 17:43
  • $\begingroup$ This question blender.stackexchange.com/q/95324 and this answer should contain enough info blender.stackexchange.com/a/39678. $\endgroup$ – GiantCowFilms May 10 '18 at 17:53
  • $\begingroup$ Sorry, I meant to say it's a mathutils direction vector. I know the origin of the object casting from, but need to use the direction vector to get a position in a certain direction from that origin. $\endgroup$ – Cameron Fazakerley May 10 '18 at 18:05
  • $\begingroup$ It seems you want to measure from one point to another. What points are that? $\endgroup$ – Monster May 14 '18 at 7:47
2
$\begingroup$

I know this is old but had to work on a similar situation tonight.

All you need to do is add the vector to your 3D point A(which should also be a vector pointing from your object to the origin point of the scene). This should give you a target point in 3D space.

target_point = point_A.worldPosition + vector

If you want to change the distance away from your point_A origin, you need only alter the magnitude of your vector:

vector.magnitude *= 5 # 5 times the vector length

or

vector.magnitude += 30 # 30 Blender units greater than your original vector
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.