Skip to content

Commit a388391

Browse files
author
andrewtliew
committed
- Couple of import fixes
1 parent 7ab4341 commit a388391

File tree

4 files changed

+39
-40
lines changed

4 files changed

+39
-40
lines changed

src/compas/hpc/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
orthonormalise_vectors_numba
6868
plane_from_points_numba
6969
circle_from_points_numba
70+
circle_from_points_xy_numba
7071
7172
7273
solvers
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from .basic import *
1+
from .basic_numba import *
22

3-
from .basic import __all__ as a
3+
from .basic_numba import __all__ as a
44

55
__all__ = a

src/compas/hpc/geometry/basic_numba.py

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from numpy import array
1111
from numpy import empty
1212
from numpy import sqrt
13-
from numpy import zeros
1413

1514
import numpy as np
1615

@@ -63,7 +62,7 @@
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)

src/compas/hpc/solvers/devo_numba.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
__email__ = '[email protected]'
2222

2323

24+
__all__ = [
25+
'devo_numba',
26+
]
27+
28+
2429
args = 0
2530

2631

0 commit comments

Comments
 (0)