summaryrefslogtreecommitdiffstats
path: root/libdimension-python
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension-python')
-rw-r--r--libdimension-python/dimension.pxd5
-rw-r--r--libdimension-python/dimension.pyx24
-rwxr-xr-xlibdimension-python/tests/demo.py8
3 files changed, 12 insertions, 25 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd
index cd28f24..22e9764 100644
--- a/libdimension-python/dimension.pxd
+++ b/libdimension-python/dimension.pxd
@@ -91,9 +91,6 @@ cdef extern from "../libdimension/dimension.h":
double dmnsn_vector_norm(dmnsn_vector v)
dmnsn_vector dmnsn_vector_normalized(dmnsn_vector v)
- double dmnsn_vector_axis_angle(dmnsn_vector v1, dmnsn_vector v2,
- dmnsn_vector axis)
-
dmnsn_vector dmnsn_zero
dmnsn_vector dmnsn_x
dmnsn_vector dmnsn_y
@@ -114,6 +111,8 @@ cdef extern from "../libdimension/dimension.h":
dmnsn_matrix dmnsn_scale_matrix(dmnsn_vector s)
dmnsn_matrix dmnsn_translation_matrix(dmnsn_vector d)
dmnsn_matrix dmnsn_rotation_matrix(dmnsn_vector theta)
+ dmnsn_matrix dmnsn_alignment_matrix(dmnsn_vector frm, dmnsn_vector to,
+ dmnsn_vector axis1, dmnsn_vector axis2)
##########
# Colors #
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index 9a5fd80..54b7e66 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -643,11 +643,7 @@ cdef class Cone(Object):
cdef Matrix trans = translate(Y)
trans = scale(1.0, dir.norm()/2, 1.0)*trans
-
- cdef double thetaX = dmnsn_vector_axis_angle(dmnsn_y, dir._v, dmnsn_x)
- cdef double thetaZ = dmnsn_vector_axis_angle(dmnsn_y, dir._v, dmnsn_z)
- trans = _rawRotate(thetaX*X)*_rawRotate(thetaZ*Z)*trans
-
+ trans = _rawMatrix(dmnsn_alignment_matrix(dmnsn_y, dir._v, dmnsn_x, dmnsn_z))*trans
trans = translate(bottom)*trans
self._intrinsicTransform(trans)
@@ -786,22 +782,14 @@ cdef class PerspectiveCamera(Camera):
cdef Vector vsky = Vector(sky)
# Line up the top of the viewport with the sky vector
- cdef double thetaSkyX = dmnsn_vector_axis_angle(dmnsn_y, vsky._v, dmnsn_x)
- cdef double thetaSkyZ = dmnsn_vector_axis_angle(dmnsn_y, vsky._v, dmnsn_z)
- cdef Matrix alignSky = _rawRotate(thetaSkyX*X)*_rawRotate(thetaSkyZ*Z)
- self.transform(alignSky)
- cdef Vector right = alignSky*X
+ cdef Matrix alignSky = _rawMatrix(dmnsn_alignment_matrix(dmnsn_y, vsky._v,
+ dmnsn_z, dmnsn_x))
cdef Vector forward = alignSky*Z
+ cdef Vector right = alignSky*X
# Line up the look at point with lookAt
- cdef double thetaLookAtSky = dmnsn_vector_axis_angle(
- forward._v, dir._v, vsky._v
- )
- cdef double thetaLookAtRight = dmnsn_vector_axis_angle(
- forward._v, dir._v, right._v
- )
- self.transform(_rawRotate(thetaLookAtSky*vsky))
- self.transform(_rawRotate(thetaLookAtRight*right))
+ self.transform(_rawMatrix(dmnsn_alignment_matrix(forward._v, dir._v,
+ vsky._v, right._v)))
# Move the camera into position
self.transform(translate(Vector(location)))
diff --git a/libdimension-python/tests/demo.py b/libdimension-python/tests/demo.py
index 4b68114..c024812 100755
--- a/libdimension-python/tests/demo.py
+++ b/libdimension-python/tests/demo.py
@@ -153,10 +153,10 @@ skySphere = SkySphere(
)
# Scene
-scene = Scene(canvas = canvas,
- objects = objects,
- lights = lights,
- camera = camera)
+scene = Scene(canvas = canvas,
+ objects = objects,
+ lights = lights,
+ camera = camera)
scene.defaultTexture = Texture(finish = Ambient(0.1) + Diffuse(0.6))
scene.background = Clear
scene.skySphere = skySphere