Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Conv {
- XYZPlane *plane;
- XYZVector *f1, *f2;
- XYZVector *U, *V, *O;
- public:
- Conv(XYZPlane *, XYZVector *, XYZVector *);
- Point *from3Dto2D(XYZPoint *) const;
- XYZPoint *from2Dto3D(Point *) const;
- };
- Conv::Conv(XYZPlane *pl, XYZVector *ff1, XYZVector *ff2) :
- plane(pl), f1(ff1), f2(ff2)
- {
- U = XYZVector::sub(ff1,ff2);
- V = XYZVector::v_mul(U,pl->normal());
- O = XYZVector::middle(ff1,ff2);
- }
- Point *Conv::from3Dto2D(XYZPoint *p) const {
- XYZVector *OP = XYZVector::sub(new XYZVector(p), O);
- double tmpx = XYZVector::s_mul(OP,U) / sqrt(XYZVector::s_mul(U,U));
- double tmpy = XYZVector::s_mul(OP,V) / sqrt(XYZVector::s_mul(V,V));
- return new Point(tmpx,tmpy);
- }
- XYZPoint *Conv::from2Dto3D(Point *p) const {
- XYZVector *UP = U->one()->mul_c(p->x);
- XYZVector *VP = V->one()->mul_c(p->y);
- XYZVector *res = XYZVector::add(UP,VP);
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement