1
$\begingroup$

Why the result of ray_cast function is giving me that result? The hit point should be Vector(0.5, -1.0, 0.0), but it is returning Vector(0.666..., -1.0, 0)

I have tried a lot of combinations to try to understand what is wrong, but no clue of what happens, so I decide to ask it here.

Results Results2

$\endgroup$
  • $\begingroup$ Yes, it is the default cube. I double check and the two vector (v1 and v2) are what is showed in the image. $\endgroup$ – Fabio Nascimento Jun 17 '16 at 16:36
  • 2
    $\begingroup$ Related blender.stackexchange.com/questions/50716/… You are ray casting from v1l in a v2l direction, it's not from-to. $\endgroup$ – batFINGER Jun 19 '16 at 13:40
  • $\begingroup$ Thanks batFINGER... In fact the function cast_ray expects a initial vector and a direction, giving by (vector2 - vector1).normalized()... Now it works as expected. $\endgroup$ – Fabio Nascimento Jun 19 '16 at 21:33
1
$\begingroup$

Thanks to batFINGER, I found the error. The ray_cast function should be supplied with a point (v1, in my example) and the normalized direction, reached by (v2 - v1).normalized(). Now it is working as expected.

Solution

$\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.