Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#***************************************************************************** # Copyright (C) 2007 Robert Bradshaw <robertwb@math.washington.edu> # # Distributed under the terms of the GNU General Public License (GPL) # # This code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ #*****************************************************************************
# Utility functions for operating on the point_c struct. from libc cimport math
cdef inline bint point_c_set(point_c* res, P) except -2: res.x, res.y, res.z = P[0], P[1], P[2]
cdef inline bint point_c_eq(point_c P, point_c Q):
cdef inline int point_c_cmp(point_c P, point_c Q): """ Lexographic order """ return 0 else: else: else:
cdef inline void point_c_update_finite_lower_bound(point_c* res, point_c P): # We use the condition "not P.x > res.x" so that the condition returns True if res.x is NaN
cdef inline void point_c_update_finite_upper_bound(point_c* res, point_c P): # We use the condition "not P.x < res.x" so that the condition returns True if res.x is NaN
cdef inline void point_c_lower_bound(point_c* res, point_c P, point_c Q):
cdef inline void point_c_upper_bound(point_c* res, point_c P, point_c Q):
cdef inline void point_c_add(point_c* res, point_c P, point_c Q):
cdef inline void point_c_sub(point_c* res, point_c P, point_c Q):
cdef inline void point_c_mul(point_c* res, point_c P, double a):
cdef inline double point_c_dot(point_c P, point_c Q):
cdef inline void point_c_cross(point_c* res, point_c P, point_c Q):
cdef inline double point_c_len(point_c P): return math.sqrt(point_c_dot(P, P))
cdef inline void point_c_transform(point_c* res, double* M, point_c P): """ M is a flattened 4x4 matrix, row major, representing an Euclidean Transformation. Operate on P as a point. """
cdef inline void point_c_stretch(point_c* res, double* M, point_c P): """ M is a flattened 4x4 matrix, row major, representing an Euclidean Transformation. Operate on P as a vector (i.e. ignore the translation component) """
cdef inline void face_c_normal(point_c* res, face_c face, point_c* vlist): cdef point_c e1, e2
cdef inline double cos_face_angle(face_c F, face_c E, point_c* vlist): cdef point_c nF, nE
cdef inline double sin_face_angle(face_c F, face_c E, point_c* vlist): cdef point_c nF, nE face_c_normal(&nF, F, vlist) face_c_normal(&nE, E, vlist) cdef double dot = point_c_dot(nF, nE) return math.sqrt(1-(dot*dot)/(point_c_dot(nF, nF)*point_c_dot(nE, nE)))
|