Skip to content

Commit f628171

Browse files
authored
Merge pull request #1118 from katarametin/fixed_is_point_in_circle_xy
Fixed `is_point_in_circle_xy` second argument to access the origin of…
2 parents 0fc9272 + ca6540c commit f628171

File tree

6 files changed

+44
-19
lines changed

6 files changed

+44
-19
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
- Gene Ting-Chun Kao <<[email protected]>> [@GeneKao](https://github.com/GeneKao)
3636
- Chen Kasirer <<[email protected]>> [@chenkasirer](https://github.com/chenkasirer)
3737
- Nickolas Maslarinos <<[email protected]>> [@nmaslarinos](https://github.com/nmaslarinos)
38+
- Katerina Toumpektsi <<[email protected]>> [@katarametin](https://github.com/katarametin)

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
* Fixed serialization of sphere and cylinder Breps in `RhinoBrep`.
3030
* Fixed serialization of some trimmed shapes in `RhinoBrep`.
3131
* Freeze black version to 22.12.0.
32-
32+
* Fixed `is_point_in_circle_xy` second argument to access the origin of the plane of the circle.
33+
3334
### Removed
3435

3536

CONTRIBUTING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ In short, this is how that works.
3636
invoke test
3737
```
3838

39-
5. Start making your changes to the **master** branch (or branch off of it).
40-
6. Auto-format your code using `black <path_to_source_file>`.
39+
5. Start making your changes to the **main** branch (or branch off of it).
40+
6. Auto-format your code using:
41+
42+
```bash
43+
invoke format
44+
```
45+
4146
7. Make sure all tests still pass:
4247

4348
```bash

src/compas/geometry/_core/constructors.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ def circle_from_points(a, b, c):
3434
3535
Returns
3636
-------
37-
[float, float, float]
38-
Center of the circle.
39-
float
40-
Radius of the circle.
41-
[float, float, float]
42-
Normal of the plane containing the circle.
37+
([float, float, float], [float, float, float]), float
38+
Center, normal and radius of the circle respectively.
4339
4440
Notes
4541
-----
@@ -71,7 +67,7 @@ def circle_from_points(a, b, c):
7167
Cc = scale_vector(c, C)
7268
center = sum_vectors([Aa, Bb, Cc])
7369
radius = length_vector(subtract_vectors(a, center))
74-
return center, radius, normal
70+
return (center, normal), radius
7571

7672

7773
def circle_from_points_xy(a, b, c):
@@ -88,12 +84,8 @@ def circle_from_points_xy(a, b, c):
8884
8985
Returns
9086
-------
91-
[float, float, 0.0]
92-
Center of the circle in the XY plane.
93-
float
94-
Radius of the circle.
95-
[0.0, 0.0, 1.0]
96-
Normal of the plane containing the circle.
87+
([float, float, float], [float, float, float]), float
88+
Center, normal and radius of the circle respectively.
9789
9890
Notes
9991
-----
@@ -124,4 +116,4 @@ def circle_from_points_xy(a, b, c):
124116
centerx = (d * e - b * f) / g
125117
centery = (a * f - c * e) / g
126118
radius = sqrt((ax - centerx) ** 2 + (ay - centery) ** 2)
127-
return [centerx, centery, 0.0], radius, [0.0, 0.0, 1.0]
119+
return ([centerx, centery, 0.0], [0.0, 0.0, 1.0]), radius

src/compas/geometry/predicates/predicates_2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def is_point_in_circle_xy(point, circle):
337337
----------
338338
point : [float, float, float] | :class:`~compas.geometry.Point`
339339
XY(Z) coordinates of a point (Z will be ignored).
340-
circle : [point, float]
340+
circle : [[point, vector], float] | :class:`~compas.geometry.Circle`
341341
Center and radius of the circle on the XY plane.
342342
343343
Returns
@@ -347,7 +347,7 @@ def is_point_in_circle_xy(point, circle):
347347
False otherwise.
348348
349349
"""
350-
dis = distance_point_point_xy(point, circle[0])
350+
dis = distance_point_point_xy(point, circle[0][0])
351351
if dis <= circle[1]:
352352
return True
353353
return False
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from compas.geometry import Circle
2+
from compas.geometry import Plane
3+
from compas.geometry import Point
4+
from compas.geometry import Vector
5+
from compas.geometry import is_point_in_circle_xy
6+
7+
8+
def test_is_point_in_circle_xy():
9+
pt = [1, 2, 0] # only testing in xy
10+
circle = [[[2, 2, 10], [0, 0, 1]], 4.7]
11+
12+
assert is_point_in_circle_xy(pt, circle) is True
13+
14+
pt_outside = [15, 15, 0]
15+
assert is_point_in_circle_xy(pt_outside, circle) is False
16+
17+
18+
def test_is_point_in_circle_xy_class_input():
19+
pt_inside = Point(1, 2, 0)
20+
plane = Plane(Point(2, 2, 10), Vector(0, 0, 1))
21+
radius = 4.7
22+
circle = Circle(plane, radius)
23+
assert is_point_in_circle_xy(pt_inside, circle) is True
24+
25+
pt_outside = Point(15, 15, 0)
26+
assert is_point_in_circle_xy(pt_outside, circle) is False

0 commit comments

Comments
 (0)