Turning 3d points on a plane to 2d co-ords?
-
I got a set of 3d points, and I would like to compare their relative position to each other on the plane. Any ideas?
-
If the plane is z=0 flat them simply make the point.z=0 for each point.
If it's an arbitrary plane then project the point to the plane using the plane's normal - or normal.reverse depending which way it's facing - as the 'line's' vector.
http://code.google.com/apis/sketchup/docs/ourdoc/geom.html#intersect_line_plane
intersecting the line with the plane returns a point where the vector hits the plane... nil if not - so you can use that if you are unsure on the vector's direction - simply do one test for an intersecting point if no point then use the reversed vector it must then intersect the plane... -
@tig said:
If it's an arbitrary plane then project the point to the plane using the plane's normal
?
the points are already on the plane. -
I'll try to spesify:
I have an arbitrary plane.
I have a set of 3d point that all lie on that planeI would like to work with them in their relative 2D co-ordinates on that plane. (I have a point that acts as origin.)
-
if you have x and y vectors:
model2plane = Geom::Transformation.axes(point,x,y,normal).inverse
(untested)otherwise you can either use
vector.cross
if you have one vector, orvector.axes
if you have neither. -
Ah1 I've overlooked that transformation method! Thanks, I'll see if I can make this work.
-
Thank you Chris! It worked like a charm! So glad you pointed that method out, as I was about to embark on a dreadful DIY reinvent the wheel journey.
-
Hopefully in some future version we'll have a Geom::Axes class that let's us instantiate as many UCS' as we need and GC them when they're no longer needed. (There would be a world WCS preset by SU of course.)
Advertisement