[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob include/vob/trans/LinearPrimitives.hxx v...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] libvob include/vob/trans/LinearPrimitives.hxx v... |
Date: |
Wed, 09 Jul 2003 10:05:25 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Janne V. Kujala <address@hidden> 03/07/09 10:05:25
Modified files:
include/vob/trans: LinearPrimitives.hxx
vob/demo/multifil: randgraph.py
Log message:
use quaternion rotation and try PS2MouseDevice
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/trans/LinearPrimitives.hxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/randgraph.py.diff?tr1=1.25&tr2=1.26&r1=text&r2=text
Patches:
Index: libvob/include/vob/trans/LinearPrimitives.hxx
diff -u libvob/include/vob/trans/LinearPrimitives.hxx:1.6
libvob/include/vob/trans/LinearPrimitives.hxx:1.7
--- libvob/include/vob/trans/LinearPrimitives.hxx:1.6 Wed May 14 18:03:30 2003
+++ libvob/include/vob/trans/LinearPrimitives.hxx Wed Jul 9 10:05:25 2003
@@ -368,6 +368,31 @@
};
VOB_PRIMITIVETRANS_DEFINED(RotateXYZ_Explicit, "rotateXYZ");
+ /** Quaternion parametrization of rotation in 3-space.
+ * Parameters: x, y, z, w
+ */
+ class RotateXYZ_Quaternion :
+ public RotateXYZ,
+ public ParametrizedPrimitiveTransform
+ {
+ public:
+ enum { NParams = 4 };
+ template<class Ptr> void setParams(Ptr p) {
+ vec.x = p[0];
+ vec.y = p[1];
+ vec.z = p[2];
+ float norm = vec.length();
+ if (norm > 0)
+ vec *= 1 / norm;
+ else
+ vec.z = 1;
+ a = 2 * acos(p[3]) * (180 / M_PI);
+
+ angleWasSet();
+ }
+ };
+ VOB_PRIMITIVETRANS_DEFINED(RotateXYZ_Quaternion, "rotateQuaternion");
+
/** Affine coordinate system (in xy), offset in z.
* Can't be used in HierarchicalTransform directly
* because parameters are required.
Index: libvob/vob/demo/multifil/randgraph.py
diff -u libvob/vob/demo/multifil/randgraph.py:1.25
libvob/vob/demo/multifil/randgraph.py:1.26
--- libvob/vob/demo/multifil/randgraph.py:1.25 Wed Jul 9 07:38:36 2003
+++ libvob/vob/demo/multifil/randgraph.py Wed Jul 9 10:05:25 2003
@@ -30,23 +30,55 @@
from vob.fillet import light3d
from vob.putil.demowindow import w
-
+from org.nongnu.libvob.input import RelativeAxisListener
from random import Random
+import math
+
+def quatmul(a, b):
+ return (
+ a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],
+ a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],
+ a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],
+ a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],
+ )
+
class Scene:
"Random graph"
def __init__(self):
+ self.rot = (0, 0, 0, 1)
+ def rotX(a): self.rot =
quatmul((0,-math.sin(.005*a),0,math.cos(.005*a)), self.rot)
+ def rotY(a): self.rot = quatmul((-math.sin(.005*a), 0, 0,
math.cos(.005*a)), self.rot)
+
self.key = KeyPresses(
self,
SlideLin("x", 200, 20, "x", "Left", "Right"),
SlideLin("y", 300, 20, "y", "Up", "Down"),
- SlideLin("ang", 0, 3, "Rotation angle", "Prior", "Next"),
- SlideLin("ang2", 0, 3, "Rotation angle 2", "Home", "End"),
+ Action("Rotate Left", "Left", lambda *x: rotX(10)),
+ Action("Rotate Right", "Right", lambda *x: rotX(-10)),
+ Action("Rotate Up", "Up", lambda *x: rotY(-10)),
+ Action("Rotate Down", "Down", lambda *x: rotY(10)),
Action("Use display list", "D", self.compile, noAnimation=1),
*light3d.commonkeys
)
self.list = None
-
+
+ class Listener(RelativeAxisListener):
+ def __init__(self, changed):
+ self.changed = changed
+
+ def changedRelative(self, x):
+ self.changed(x)
+ vob.AbstractUpdateManager.setNoAnimation()
+ vob.AbstractUpdateManager.chg()
+
+ if 0:
+ self.ps2 = vob.input.impl.PS2MouseDevice("/dev/input/mouse1",
"main",
+
vob.input.impl.PS2MouseDevice.IMPS_PROTO)
+ self.naxes = len(self.ps2.getAxes())
+ self.ps2.getAxes()[0].setMainListener(Listener(rotX))
+ self.ps2.getAxes()[1].setMainListener(Listener(rotY))
+
def compile(self, *args):
if self.list:
self.list = None
@@ -110,10 +142,8 @@
0.5 * size.height,
0.5 * box);
- cs = vs.coords.rotateXYZ(cs, 0, 1, 0, self.ang);
+ cs = vs.coords.rotateQuaternion(cs, *self.rot)
vs.matcher.add(cs, "Rot")
- cs = vs.coords.rotateXYZ(cs, 1, 0, 0, self.ang2);
- vs.matcher.add(cs, "Rot2")
if self.list:
vs.put(self.list, cs)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] libvob include/vob/trans/LinearPrimitives.hxx v...,
Janne V. Kujala <=