gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] libvob/include/vob/trans LinearPrimitives.hxx


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob/include/vob/trans LinearPrimitives.hxx
Date: Wed, 16 Apr 2003 06:19:50 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/04/16 06:19:50

Modified files:
        include/vob/trans: LinearPrimitives.hxx 

Log message:
        Add nadirunitsq

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/LinearPrimitives.hxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: libvob/include/vob/trans/LinearPrimitives.hxx
diff -u libvob/include/vob/trans/LinearPrimitives.hxx:1.2 
libvob/include/vob/trans/LinearPrimitives.hxx:1.3
--- libvob/include/vob/trans/LinearPrimitives.hxx:1.2   Tue Apr  1 07:53:56 2003
+++ libvob/include/vob/trans/LinearPrimitives.hxx       Wed Apr 16 06:19:50 2003
@@ -172,6 +172,76 @@
     };
     VOB_PRIMITIVETRANS_DEFINED(RotateXY_Explicit, "rotate");
 
+    /** Rotation clockwise around given point. 
+     */
+    class RotateCenteredXY :
+       public PrimitiveTransform,
+       public GLPerformablePrimitiveTransform 
+    {
+    protected:
+       float a;
+       float ox, oy;
+       void angleWasSet() {
+           s = sin(a * M_PI / 180);
+           c = cos(a * M_PI / 180);
+       }
+    private:
+       float s, c;
+    public:
+       RotateCenteredXY() { }
+       RotateCenteredXY(float angle) {
+           a = angle;
+           angleWasSet();
+       }
+       /** Perform the internal transformation of this 
+        * coordsys.
+        */
+       void tr(const ZPt &from, ZPt &to) const {
+           float x = from.x - ox;
+           float y = from.y - oy;
+           to.x = c * x + -s * y + ox; 
+           to.y = s * x + c * y + oy; 
+           to.z = from.z;
+       }
+        void performGL() const {
+           glTranslatef(ox, oy, 0);
+           glRotatef(a, 0, 0, 1);
+           glTranslatef(-ox, -oy, 0);
+       }
+       typedef RotateCenteredXY InverseType;
+       void inverse(InverseType &into) const {
+           into.a = -a;
+           into.ox = ox;
+           into.oy = oy;
+           into.angleWasSet();
+       }
+    };
+
+
+    /** Nadir rotation around unit square center.
+     */
+    class NadirUnitSq :
+       public RotateCenteredXY,
+       public DependentPrimitiveTransform {
+    public:
+       enum { NDepends = 2 }; // parent and nadir
+       template<class SPtr> void setParams(SPtr depends) {
+           Pt p = depends[0]->getSqSize();
+           ox = p.x/2;
+           oy = p.y/2;
+           ZPt origin = depends[0]->transform(ZPt(ox, oy, 0));
+           ZPt nadir = depends[1]->transform(ZPt(0,0,0));
+
+           float x = origin.x - nadir.x;
+           float y = origin.y - nadir.y;
+           float angle = atan2(x, -y);
+
+           a = angle * 180 / M_PI;
+
+       }
+    };
+    VOB_PRIMITIVETRANS_DEFINED(NadirUnitSq, "nadirUnitSq");
+
     /** A no-op: same coords in and out.
      */
     class Unit : 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]