1010from numpy import array
1111from numpy import empty
1212from numpy import sqrt
13- from numpy import zeros
1413
1514import numpy as np
1615
6362 'orthonormalise_vectors_numba' ,
6463 'plane_from_points_numba' ,
6564 'circle_from_points_numba' ,
66- # 'circle_from_points_xy_numba',
65+ 'circle_from_points_xy_numba' ,
6766]
6867
6968
@@ -803,39 +802,33 @@ def circle_from_points_numba(a, b, c):
803802 return cr
804803
805804
806- # @jit(f8[:](f8[:], f8[:], f8[:]), nogil=True, nopython=True, parallel=True)
807- # def circle_from_points_xy_numba(u, v, w):
808- # """Construct a circle from three points assumed to be in the XY plan
809-
810- # Parameter
811- # ---------
812- # a (array): XY(Z) components of the base point
813- # b (array): XY(Z) components of the second point
814- # c (array): XY(Z) components of the third point
815-
816- # Returns
817- # -------
818- # array: (x, y, z, r) where x, y, z are coords of the centre point and r the radius.
819- # """
820- # ax, ay = u[0], u[1]
821- # bx, by = v[0], v[1]
822- # cx, cy = w[0], w[1]
823- # a = bx - ax
824- # b = by - ay
825- # c = cx - ax
826- # d = cy - ay
827- # e = a * (ax + bx) + b * (ay + by)
828- # f = c * (ax + cx) + d * (ay + cy)
829- # g = 2 * (a * (cy - by) - b * (cx - bx))
830- # centrex = (d * e - b * f) / g
831- # centrey = (a * f - c * e) / g
832- # radius = sqrt((ax - centrex) ** 2 + (ay - centrey) ** 2)
833- # cr = array([
834- # centrex,
835- # centrey,
836- # 0.0,
837- # radius])
838- # return cr
805+ @jit (f8 [:](f8 [:], f8 [:], f8 [:]), nogil = True , nopython = True , parallel = True )
806+ def circle_from_points_xy_numba (u , v , w ):
807+ """Construct a circle from three points assumed to be in the XY plane.
808+
809+ Parameters
810+ ----------
811+ u (array): XY(Z) components of the base point.
812+ v (array): XY(Z) components of the second point.
813+ w (array): XY(Z) components of the third point.
814+ Returns
815+ -------
816+ array: (x, y, z, r) where x, y, z are coords of the centre point and r the radius.
817+ """
818+ ax , ay = u [0 ], u [1 ]
819+ bx , by = v [0 ], v [1 ]
820+ cx , cy = w [0 ], w [1 ]
821+ a = bx - ax
822+ b = by - ay
823+ c = cx - ax
824+ d = cy - ay
825+ e = a * (ax + bx ) + b * (ay + by )
826+ f = c * (ax + cx ) + d * (ay + cy )
827+ g = 2 * (a * (cy - by ) - b * (cx - bx ))
828+ centrex = (d * e - b * f ) / g
829+ centrey = (a * f - c * e ) / g
830+ radius = sqrt ((ax - centrex )** 2 + (ay - centrey )** 2 )
831+ return array ([centrex , centrey , 0.0 , radius ])
839832
840833
841834# ==============================================================================
@@ -849,7 +842,7 @@ def circle_from_points_numba(a, b, c):
849842 u = array ([1. , 2. , 3. ])
850843 v = array ([4. , 5. , 6. ])
851844 w = array ([5. , 2. , 10. ])
852- c = array ([[1. , 2. , 3. ], [4. , 4. , 4. ], [ 2. , 3. , 3. ] ])
845+ c = array ([[1. , 2. , 3. ], [4. , 4. , 4. ]])
853846 d = array ([4. , 5. ])
854847 e = array ([[1. , 2. ], [0. , 2. ]])
855848 f = array ([[4. , 5. ], [1. , 2. ]])
@@ -900,7 +893,7 @@ def circle_from_points_numba(a, b, c):
900893 # transpose_matrix_numba(e)
901894 # orthonormalise_vectors_numba(c)
902895 # plane_from_points_numba(u, v, w)
903- circle_from_points_numba (u , v , w )
904- # circle_from_points_xy_numba(u, v, w)
896+ # circle_from_points_numba(u, v, w)
897+ circle_from_points_xy_numba (u , v , w )
905898
906899 print (time () - tic )
0 commit comments