diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-09-03 15:55:19 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-10-25 11:03:56 -0400 |
commit | b554b20c8d59d6046bdcec7c79fb61cd0e65811c (patch) | |
tree | a6c6f257cfaffcec953be7c0cce180f7a8855c68 /libdimension-python | |
parent | b2cf35c26d5263f3079480208429e3a1d7dd2373 (diff) | |
download | dimension-b554b20c8d59d6046bdcec7c79fb61cd0e65811c.tar.xz |
math: Make vectors have an array instead of different fields.
Diffstat (limited to 'libdimension-python')
-rw-r--r-- | libdimension-python/dimension.pxd | 5 | ||||
-rw-r--r-- | libdimension-python/dimension.pyx | 8 |
2 files changed, 5 insertions, 8 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd index cb152be..4edfbf2 100644 --- a/libdimension-python/dimension.pxd +++ b/libdimension-python/dimension.pxd @@ -115,9 +115,7 @@ cdef extern from "../libdimension/dimension.h": double dmnsn_degrees(double radians) ctypedef struct dmnsn_vector: - double x - double y - double z + double n[3] dmnsn_vector dmnsn_new_vector(double x, double y, double z) @@ -126,7 +124,6 @@ cdef extern from "../libdimension/dimension.h": dmnsn_vector dmnsn_vector_add(dmnsn_vector lhs, dmnsn_vector rhs) dmnsn_vector dmnsn_vector_sub(dmnsn_vector lhs, dmnsn_vector rhs) dmnsn_vector dmnsn_vector_mul(double lhs, dmnsn_vector rhs) - dmnsn_vector dmnsn_vector_div(dmnsn_vector lhs, double rhs) dmnsn_vector dmnsn_vector_cross(dmnsn_vector lhs, dmnsn_vector rhs) double dmnsn_vector_dot(dmnsn_vector lhs, dmnsn_vector rhs) diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx index 34d720e..77c9cd8 100644 --- a/libdimension-python/dimension.pyx +++ b/libdimension-python/dimension.pyx @@ -234,15 +234,15 @@ cdef class Vector: property x: """The x coordinate.""" def __get__(self): - return self._v.x + return self._v.n[0] property y: """The y coordinate.""" def __get__(self): - return self._v.y + return self._v.n[1] property z: """The z coordinate.""" def __get__(self): - return self._v.z + return self._v.n[2] def __pos__(self): return self @@ -261,7 +261,7 @@ cdef class Vector: else: return _Vector(dmnsn_vector_mul(lhs, (<Vector?>rhs)._v)) def __truediv__(Vector lhs not None, double rhs): - return _Vector(dmnsn_vector_div(lhs._v, rhs)) + return _Vector(dmnsn_vector_mul(1.0/rhs, lhs._v)) def __richcmp__(lhs, rhs, int op): equal = (Vector(lhs) - Vector(rhs)).norm() < dmnsn_epsilon |