Skip to content

Commit

Permalink
fix bugs in shape conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Aug 23, 2024
1 parent 4720aaa commit 86d9abd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Changed supported Blender versions to latest LTS versions (3.3, 3.6, 4.2).
* Fixed bug in `compas_rhino.conversions.cone_to_compas`.
* Fixed bug in `compas_rhino.conversions.cylinder_to_compas`.

### Removed

Expand Down
15 changes: 6 additions & 9 deletions src/compas_rhino/conversions/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import scriptcontext as sc # type: ignore

from compas.geometry import Box
from compas.geometry import Circle
from compas.geometry import Cone
from compas.geometry import Cylinder
from compas.geometry import Frame
from compas.geometry import Plane
from compas.geometry import Sphere
from compas.geometry import Torus

Expand All @@ -19,11 +17,9 @@

# from .geometry import plane_to_rhino
from .geometry import frame_to_rhino
from .geometry import plane_to_compas
from .geometry import plane_to_compas_frame
from .geometry import point_to_compas
from .geometry import point_to_rhino
from .geometry import vector_to_compas

# =============================================================================
# To Rhino
Expand Down Expand Up @@ -253,8 +249,9 @@ def cone_to_compas(cone):
:class:`compas.geometry.Cone`
"""
plane = Plane(cone.BasePoint, vector_to_compas(cone.Plane.Normal).inverted())
return Cone(Circle(plane, cone.Radius), cone.Height)
frame = plane_to_compas_frame(cone.Plane)
frame.point = point_to_compas(cone.BasePoint) # invert the z-axis?
return Cone(radius=cone.Radius, height=cone.Height, frame=frame)


def cylinder_to_compas(cylinder):
Expand All @@ -269,10 +266,10 @@ def cylinder_to_compas(cylinder):
:class:`compas.geometry.Cylinder`
"""
plane = plane_to_compas(cylinder.BasePlane)
frame = plane_to_compas_frame(cylinder.BasePlane)
height = cylinder.TotalHeight
plane.point += plane.normal * (0.5 * height)
return Cylinder(Circle(plane, cylinder.Radius), height)
frame.point += frame.normal * (0.5 * height)
return Cylinder(radius=cylinder.Radius, height=height, frame=frame)


def torus_to_compas(torus):
Expand Down

0 comments on commit 86d9abd

Please sign in to comment.