Skip to content

Commit 43695d8

Browse files
authored
Merge pull request #1203 from compas-dev/frame-default-params-in-ctor
Optional args in frame constructor
2 parents f6e9a79 + bceac03 commit 43695d8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
* Pinned `jsonschema` version to >=4.17, <4.18 to avoid Rust toolchain
2121
* Fixed `box_to_compas` in `compas_rhino.conversions` to correctly take in the center of the box as the center point of the frame.
2222
* Removed `cython` from requirements.
23+
* Made X and Y axis optional in the constructor of `Frame`.
2324

2425
### Removed
2526

src/compas/geometry/frame.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class Frame(Geometry):
3131
----------
3232
point : [float, float, float] | :class:`~compas.geometry.Point`
3333
The origin of the frame.
34-
xaxis : [float, float, float] | :class:`~compas.geometry.Vector`
35-
The x-axis of the frame.
36-
yaxis : [float, float, float] | :class:`~compas.geometry.Vector`
37-
The y-axis of the frame.
34+
xaxis : [float, float, float] | :class:`~compas.geometry.Vector`, optional
35+
The x-axis of the frame. Defaults to the unit X vector.
36+
yaxis : [float, float, float] | :class:`~compas.geometry.Vector`, optional
37+
The y-axis of the frame. Defaults to the unit Y vector.
3838
3939
Attributes
4040
----------
@@ -77,15 +77,15 @@ class Frame(Geometry):
7777
"required": ["point", "xaxis", "yaxis"],
7878
}
7979

80-
def __init__(self, point, xaxis, yaxis, **kwargs):
80+
def __init__(self, point, xaxis=None, yaxis=None, **kwargs):
8181
super(Frame, self).__init__(**kwargs)
8282
self._point = None
8383
self._xaxis = None
8484
self._yaxis = None
8585
self._zaxis = None
8686
self.point = point
87-
self.xaxis = xaxis
88-
self.yaxis = yaxis
87+
self.xaxis = xaxis or Vector(1, 0, 0)
88+
self.yaxis = yaxis or Vector(0, 1, 0)
8989

9090
def __repr__(self):
9191
return "{0}(point={1!r}, xaxis={2!r}, yaxis={3!r})".format(

0 commit comments

Comments
 (0)