Page MenuHome

Add 3d to 2d plane mapping functions to math lib
ClosedPublic

Authored by Luca Rood (LucaRood) on Jan 11 2017, 2:47 AM.

Details

Summary

This diff adds two functions to project 3d coordinates onto a 3d plane, to get 2d coordinates, essentially eliminating the plane's normal axis from the coordinates. This allows the use of 2d computations on the projected geometry which often makes things more straight forward and more efficient. For instance, you can check if a point is inside a polygon using these 2d projected coordinates.

The first function (map_to_plane_v2_v3v3) takes a 3d point and a normal, and gives you 2d coordinates with the normal axis factored out.

The second function (map_to_plane_axis_angle_v2_v3v3fl) is there for performance reasons. The first mapping function has to calculate the angle and axis of rotation between the given normal and a global z axis (i.e. {0, 0, 1}). When one has to project multiple points onto the same plane, using map_to_plane_axis_angle_v2_v3v3fl is recommended, which unlike the first one, directly takes the angle and axis I mentioned instead of computing them from the normal, thus saving those redundant computations for every point.

Diff Detail

Repository
rB Blender

Event Timeline

Luca Rood (LucaRood) retitled this revision from to Add 3d to 2d plane mapping functions to math lib.
Luca Rood (LucaRood) updated this object.
Luca Rood (LucaRood) set the repository for this revision to rB Blender.
Bastien Montagne (mont29) edited edge metadata.

Besides point noted below, lgtm.

source/blender/blenlib/intern/math_geom.c
4063

Should rather use angle_normalized_v3v3 imho (and call could be inlined in map_to_plane_axis_angle call below too, would save a variable, even though compiler is most likely smart enough to optimize it out anyway).

This revision is now accepted and ready to land.Jan 13 2017, 10:27 AM
This revision was automatically updated to reflect the committed changes.