1

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 :)

  • Do you wish to cast the ray from the objects origin? A specific point on the object? – GiantCowFilms May 10 '18 at 17:38
  • from the origin, using the vector – Cameron Fazakerley May 10 '18 at 17:43
  • This question https://blender.stackexchange.com/q/95324 and this answer should contain enough info https://blender.stackexchange.com/a/39678. – GiantCowFilms May 10 '18 at 17:53
  • 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. – Cameron Fazakerley May 10 '18 at 18:05
  • It seems you want to measure from one point to another. What points are that? – Monster May 14 '18 at 07:47
  • Sorry, I think I was unclear. I don't need to measure distance, that'd just be pythagoras. My intent is to take a vector V and 3D point A, then use them to find the coords of a point x distance away from point A in direction V – Cameron Fazakerley May 14 '18 at 13:03
  • To points in space A and B the direction vector A to B is D = B - A. The distance from A to B is D.length. Normalize it and and any point from A traveling x along D is P = A + xD. ( d = a + x * d.normalized() ) – batFINGER Nov 30 '18 at 08:31

1 Answers1

2

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
sodsm live
  • 21
  • 2