vb.net - Convert 3D plane (front view of a solid) to 2D coordinates (XY plane) -


in program, have solid in top view cut using cutting plane (by drawing line on top view - xy plane). after solid cut using line, have show front face of cut part on xy plane can print diagram of cross section on paper. once have rectangle of cut face (in front view - xz plane) , have transform show in xy plane. how can using vb.net.

i saw question here: convert 3d plane 2d , code provided user kieth. solution relevant problem?

edit: edit related nico schertler's answer. read on vectors , basic coordinate geometry. how should direction vector? example, cut line cuts solid cube defined by: stpt(-1500, 24038, 0) , edpt(45500, 24038, 0). cut face of solid rectangle: pt1(-350, 24038, 0), pt2(1335, 24038, 0), pt3(1335, 24038, -350) , pt4(-350, 24038, -350). have transform each coordinate of rectangle, lying in xy plane. xz plane. here, direction vector direction of cut line or each edge of rectangle? hope not confusing anyone.

you want transform 3d-points local 2d coordinate system. need several things that:

the coordinates of local origin. might center of mass of cut shape or point average. anyway, should lie in same plane cut shape.

the direction of local up-vector. (0, 0, 1) because don't transform direction.

the direction of local right-vector. given cut line's direction. of form (rx, ry, 0). vector should normalized.

then can calculate local coordinates (u, v) of 3d point p follows:

d = p - origin; u = dot(d, rightvector); v = dot(d, upvector); //this d.z because upvector=(0,0,1) 

you can use local coordinates (u, v) display cut shape. can expressed using matrix:

/ u \   / rightvector.x  rightvector.y  rightvector.z \   / d.x \ \ v / = \ upvector.x     upvector.y     upvector.z    / * | d.y |                                                           \ d.z / 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -