/usr/lib/python2.7/dist-packages/PySPH-1.0a4.dev0-py2.7-linux-x86_64.egg/pysph/base/point.pxd is in python-pysph 0~20160514.git91867dc-4build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | cimport numpy
cdef extern from "math.h":
double sqrt(double) nogil
double ceil(double) nogil
cdef extern from 'limits.h':
cdef int INT_MAX
cdef struct cPoint:
double x, y, z
cdef inline cPoint cPoint_new(double x, double y, double z):
cdef cPoint p = cPoint(x,y,z)
return p
cdef inline cPoint cPoint_sub(cPoint pa, cPoint pb):
return cPoint_new(pa.x-pb.x, pa.y-pb.y, pa.z-pb.z)
cdef inline cPoint cPoint_add(cPoint pa, cPoint pb):
return cPoint_new(pa.x+pb.x, pa.y+pb.y, pa.z+pb.z)
cdef inline double cPoint_dot(cPoint pa, cPoint pb):
return pa.x*pb.x + pa.y*pb.y + pa.z*pb.z
cdef inline double cPoint_norm(cPoint p):
return p.x*p.x + p.y*p.y + p.z*p.z
cdef inline double cPoint_distance(cPoint pa, cPoint pb):
return sqrt((pa.x-pb.x)*(pa.x-pb.x) +
(pa.y-pb.y)*(pa.y-pb.y) +
(pa.z-pb.z)*(pa.z-pb.z)
)
cdef inline double cPoint_distance2(cPoint pa, cPoint pb):
return ((pa.x-pb.x)*(pa.x-pb.x) + (pa.y-pb.y)*(pa.y-pb.y) +
(pa.z-pb.z)*(pa.z-pb.z))
cdef inline double cPoint_length(cPoint pa):
return sqrt(cPoint_norm(pa))
cdef inline cPoint cPoint_scale(cPoint p, double k):
return cPoint_new(p.x*k, p.y*k, p.z*k)
cdef inline cPoint normalized(cPoint p):
cdef double norm = cPoint_length(p)
return cPoint_new(p.x/norm, p.y/norm, p.z/norm)
cdef class Point:
""" Class to represent point in 3D. """
cdef cPoint data
cpdef set(self, double x, double y, double z)
cdef set_from_cPoint(self, cPoint value)
cpdef numpy.ndarray asarray(self)
cpdef double norm(self)
cpdef double length(self)
cpdef double dot(self, Point p)
cpdef Point cross(self, Point p)
cpdef double distance(self, Point p)
cdef cPoint to_cPoint(self)
cdef inline Point Point_new(double x, double y, double z):
cdef Point p = Point.__new__(Point)
p.x = x
p.y = y
p.z = z
return p
cdef inline Point Point_sub(Point pa, Point pb):
return Point_new(pa.x-pb.x, pa.y-pb.y, pa.z-pb.z)
cdef inline Point Point_add(Point pa, Point pb):
return Point_new(pa.x+pb.x, pa.y+pb.y, pa.z+pb.z)
cdef inline double Point_length(Point p):
return sqrt(p.x*p.x + p.y*p.y + p.z*p.z)
cdef inline double Point_length2(Point p):
return p.x*p.x + p.y*p.y + p.z*p.z
cdef inline double Point_distance(Point pa, Point pb):
return sqrt((pa.x-pb.x)*(pa.x-pb.x) +
(pa.y-pb.y)*(pa.y-pb.y) +
(pa.z-pb.z)*(pa.z-pb.z)
)
cdef inline double Point_distance2(Point pa, Point pb):
return ((pa.x-pb.x)*(pa.x-pb.x) + (pa.y-pb.y)*(pa.y-pb.y) +
(pa.z-pb.z)*(pa.z-pb.z))
cdef inline Point Point_from_cPoint(cPoint p):
return Point_new(p.x, p.y, p.z)
cdef struct cIntPoint:
int x, y, z
cdef inline cIntPoint cIntPoint_new(int x, int y, int z):
cdef cIntPoint p = cIntPoint(x,y,z)
return p
cdef inline cIntPoint cIntPoint_sub(cIntPoint pa, cIntPoint pb):
return cIntPoint_new(pa.x-pb.x, pa.y-pb.y, pa.z-pb.z)
cdef inline cIntPoint cIntPoint_add(cIntPoint pa, cIntPoint pb):
return cIntPoint_new(pa.x+pb.x, pa.y+pb.y, pa.z+pb.z)
cdef inline long cIntPoint_dot(cIntPoint pa, cIntPoint pb):
return pa.x*pb.x + pa.y*pb.y + pa.z*pb.z
cdef inline long cIntPoint_norm(cIntPoint p):
return p.x*p.x + p.y*p.y + p.z*p.z
cdef inline double cIntPoint_length(cIntPoint pa):
return sqrt(<double>cIntPoint_norm(pa))
cdef inline long cIntPoint_distance2(cIntPoint pa, cIntPoint pb):
return ((pa.x-pb.x)*(pa.x-pb.x) +
(pa.y-pb.y)*(pa.y-pb.y) +
(pa.z-pb.z)*(pa.z-pb.z))
cdef inline double cIntPoint_distance(cIntPoint pa, cIntPoint pb):
return sqrt(<double>cIntPoint_distance2(pa, pb))
cdef inline cIntPoint cIntPoint_scale(cIntPoint p, int k):
return cIntPoint_new(p.x*k, p.y*k, p.z*k)
cdef inline bint cIntPoint_is_equal(cIntPoint pa, cIntPoint pb):
return (pa.x == pb.x and pa.y == pb.y and pa.z == pb.z)
cdef class IntPoint:
cdef cIntPoint data
cpdef numpy.ndarray asarray(self)
cdef bint is_equal(self, IntPoint)
cdef IntPoint diff(self, IntPoint)
cdef tuple to_tuple(self)
cdef IntPoint copy(self)
cdef inline IntPoint IntPoint_sub(IntPoint pa, IntPoint pb):
return IntPoint_new(pa.x-pb.x, pa.y-pb.y, pa.z-pb.z)
cdef inline IntPoint IntPoint_add(IntPoint pa, IntPoint pb):
return IntPoint_new(pa.x+pb.x, pa.y+pb.y, pa.z+pb.z)
cdef inline IntPoint IntPoint_new(int x, int y, int z):
cdef IntPoint p = IntPoint.__new__(IntPoint)
p.data.x = x
p.data.y = y
p.data.z = z
return p
cdef inline IntPoint IntPoint_from_cIntPoint(cIntPoint p):
return IntPoint_new(p.x, p.y, p.z)
|