From 4dde640671a8278ff6c41ef21f03ba351828009c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 17 Dec 2011 16:43:19 -0500 Subject: Make triangles smooth. --- libdimension-python/dimension.pyx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libdimension-python/dimension.pyx') 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): -- cgit v1.2.3