From 6e38d819bb543b7c92f821c1e7947ca2ec39295e Mon Sep 17 00:00:00 2001 From: ganovelli Date: Tue, 9 Nov 2004 15:49:07 +0000 Subject: [PATCH] added GetUV --- vcg/space/point3.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/vcg/space/point3.h b/vcg/space/point3.h index ed360b3e..fad39566 100644 --- a/vcg/space/point3.h +++ b/vcg/space/point3.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.18 2004/10/13 12:45:51 cignoni +Better Doxygen documentation + Revision 1.17 2004/09/10 14:01:40 cignoni Added polar to cartesian @@ -88,7 +91,7 @@ protected: public: typedef P3ScalarType ScalarType; - + enum {Dimension = 3}; //@{ @@ -456,6 +459,31 @@ P3ScalarType PSDist( const Point3 & p, } +template +void GetUV( Point3 &n,Point3 &u, Point3 &v, Point3 up=Point3(0,1,0)) +{ + n.Normalize(); + const double LocEps=double(1e-7); + u=n^up; + double len = u.Norm(); + if(len < LocEps) + { + if(fabs(n[0])(1,0,0); // x is the min + else up=Point3(0,0,1); // z is the min + }else { + if(fabs(n[1])(0,1,0); // y is the min + else up=Point3(0,0,1); // z is the min + } + u=n^up; + } + u.Normalize(); + v=n^u; + v.Normalize(); + Point3 uv=u^v; +} + + typedef Point3 Point3s; typedef Point3 Point3i; typedef Point3 Point3f;