0
$\begingroup$

How can I get mirrored vector(point) by Plane by using blender python modules?

Plane will be defined as

  • plane_normal : Vector
  • plane_position : Vector

I need to know function like

def get_mirrored_vector(point, plane_position, plane_normal):
    Do Something
    return mirrored_point

actually, It sounds more of mathematical problem but I thought there might be existing function on mathutils or other blender modules

$\endgroup$
1
$\begingroup$

You can use mathutils.geometry.intersect_line_plane to project the point onto the plane. This can be done by intersecting the line defined by the point and the point offset by the plane's normal vector with the plane:

proj = intersect_line_plane(point, point + plane_normal, plane_position, plane_normal)

Once you have the projected point you can use the vector from the original point to the projection to get the mirrored point.

from mathutils.geometry import intersect_line_plane

def get_mirrored_vector(point, plane_position, plane_normal):
    proj = intersect_line_plane(point, point + plane_normal, plane_position, plane_normal)
    mirrored_point = 2 * proj - point
    return mirrored_point
$\endgroup$
  • $\begingroup$ Thank you very much for the answer with exact code! I didn't come up with the idea to use line / plane intersection function to use for this purpose. The code worked perfectly, Thank you. $\endgroup$ – Miumiu Aug 8 '18 at 9:53

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.