summaryrefslogtreecommitdiffstats
path: root/libdimension-python
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-12-17 16:43:19 -0500
committerTavian Barnes <tavianator@gmail.com>2011-12-17 17:49:00 -0500
commit4dde640671a8278ff6c41ef21f03ba351828009c (patch)
tree4ab145084a16a6af07ff53d606c40464f8cabec0 /libdimension-python
parent65b1d1998f560c03c7cc204b0ee4f5c9c4f517e0 (diff)
downloaddimension-4dde640671a8278ff6c41ef21f03ba351828009c.tar.xz
Make triangles smooth.
Diffstat (limited to 'libdimension-python')
-rw-r--r--libdimension-python/dimension.pxd8
-rw-r--r--libdimension-python/dimension.pyx15
2 files changed, 19 insertions, 4 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd
index 0d0fcc4..3f89e71 100644
--- a/libdimension-python/dimension.pxd
+++ b/libdimension-python/dimension.pxd
@@ -321,9 +321,15 @@ cdef extern from "../libdimension/dimension.h":
dmnsn_object *dmnsn_new_object()
void dmnsn_delete_object(dmnsn_object *object)
+ dmnsn_object *dmnsn_new_flat_triangle(dmnsn_vector a,
+ dmnsn_vector b,
+ dmnsn_vector c)
dmnsn_object *dmnsn_new_triangle(dmnsn_vector a,
dmnsn_vector b,
- dmnsn_vector c)
+ dmnsn_vector c,
+ dmnsn_vector na,
+ dmnsn_vector nb,
+ dmnsn_vector nc)
dmnsn_object *dmnsn_new_plane(dmnsn_vector normal)
dmnsn_object *dmnsn_new_sphere()
dmnsn_object *dmnsn_new_cube()
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index 6a76974..a34d2eb 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -1124,16 +1124,25 @@ cdef class Object(_Transformable):
cdef class Triangle(Object):
"""A triangle."""
- def __init__(self, a, b, c, *args, **kwargs):
+ def __init__(self, a, b, c, a_normal = None, b_normal = None, c_normal = None,
+ *args, **kwargs):
"""
Create a Triangle.
Keyword arguments:
- a, b, c -- the corners of the triangle
+ a, b, c -- the corners of the triangle
+ a_normal, b_normal, c_normal -- the optional normal vectors at those corners
Additionally, Triangle() accepts any arguments that Object() accepts.
"""
- self._object = dmnsn_new_triangle(Vector(a)._v, Vector(b)._v, Vector(c)._v)
+ if a_normal is None and b_normal is None and c_normal is None:
+ a_normal = cross(b - a, c - a)
+ b_normal = a_normal
+ c_normal = a_normal
+ self._object = dmnsn_new_triangle(Vector(a)._v, Vector(b)._v, Vector(c)._v,
+ Vector(a_normal)._v,
+ Vector(b_normal)._v,
+ Vector(c_normal)._v)
Object.__init__(self, *args, **kwargs)
cdef class Plane(Object):