Skip to content

Commit a36573e

Browse files
committed
Merge branch 'main' into polyline_functions
2 parents 1d7f2fb + 9affb21 commit a36573e

File tree

6 files changed

+75
-8
lines changed

6 files changed

+75
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Added
1212
* Added `divide_polyline`, `divide_polyline_by_length`, `Polyline.split_at_corners` and `Polyline.tangent_at_point_on_polyline`.
1313

14+
* Added the magic method `__str__` to `compas.geoemetry.Transformation`.
15+
1416
### Changed
1517

1618
* Fixed bug where mimic joints were considered configurable.
19+
* Fixed bug where `!=` gave incorrect results in Rhino for some compas objects.
1720

1821
### Removed
1922

docs/gettingstarted/blender.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ Note that the path ``~/Blender/2.91`` might be different for your setup.
9292
</div>
9393
</div>
9494

95+
Add-ons
96+
=======
97+
98+
For some Blender add-ons, not only the version of Python has to match, but also the version of Numpy.
99+
For example, `Sverchok <http://nortikin.github.io/sverchok/>`_, a Grasshopper-type visual programming tool for Blender,
100+
will not work with the version of Numpy included in the latest COMPAS releases, even though Blender will.
101+
102+
In those cases, you can simply revert to an earlier version of Numpy that is still compatible with COMPAS
103+
in the environment you use with Blender. For Sverchok, this would be version ``1.17.5``,
104+
which is the one shipped with Blender originally. To revert simply do
105+
106+
.. code-block:: bash
107+
108+
conda activate blender
109+
conda install numpy=1.17.5
95110
96111
Verify setup
97112
============
@@ -105,7 +120,6 @@ In Blender, at the interactive Python prompt (>>>) import the following packages
105120
>>> import numpy
106121
>>> import scipy
107122
108-
109123
Install Python packages
110124
=======================
111125

@@ -125,7 +139,6 @@ Otherwise, the changes will not have any effect.
125139
If you want to use blender with a different environment,
126140
you simply have to activate that environment and follow the same procedure described above.
127141

128-
129142
Start Blender
130143
=============
131144

@@ -232,7 +245,6 @@ Especially for code that relies heavily on libraries such as Numpy and Scipy thi
232245
artist = MeshArtist(mesh)
233246
artist.draw_mesh()
234247
235-
236248
Data Blocks
237249
-----------
238250

@@ -249,19 +261,16 @@ you will accumulate the data blocks from previous runs and after a while Blender
249261
``compas_blender.clear()`` attempts to clean up not only the scene objects but also the data blocks.
250262
If somehow you still experience a slowdown, restarting Blender will help (all unused data blocks are then automatically removed).
251263

252-
253264
Layers
254265
------
255266

256267
There are no real layers in Blender; at least not like the layers in, for example, Rhino.
257268
Therefore, the Blender artists have no optional ``layer`` parameter and no ``clear_layer`` method.
258269
Instead, objects are grouped in collections, which can be turned on and off in the Blender UI similar to layers in Rhino.
259270

260-
261271
Collections
262272
-----------
263273

264-
265274
Limitations
266275
===========
267276

src/compas/geometry/primitives/_primitive.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class Primitive(Base):
1818
def __init__(self):
1919
super(Primitive, self).__init__()
2020

21+
def __ne__(self, other):
22+
# this is not obvious to ironpython
23+
return not self.__eq__(other)
24+
2125
@classmethod
2226
def from_json(cls, filepath):
2327
"""Construct a primitive from structured data contained in a json file.

src/compas/geometry/transformations/transformation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,20 @@ def __eq__(self, other, tol=1e-05):
9797
except BaseException:
9898
return False
9999

100+
def __ne__(self, other):
101+
# this is not obvious to ironpython
102+
return not self.__eq__(other)
103+
100104
def __repr__(self):
101105
return "Transformation({})".format(self.matrix)
102106

107+
def __str__(self):
108+
s = "[[%s],\n" % ",".join([("%.4f" % n).rjust(10) for n in self.matrix[0]])
109+
s += " [%s],\n" % ",".join([("%.4f" % n).rjust(10) for n in self.matrix[1]])
110+
s += " [%s],\n" % ",".join([("%.4f" % n).rjust(10) for n in self.matrix[2]])
111+
s += " [%s]]\n" % ",".join([("%.4f" % n).rjust(10) for n in self.matrix[3]])
112+
return s
113+
103114
def __len__(self):
104115
return len(self.matrix)
105116

tests/compas/geometry/test_point.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ def test_point_operators():
1313
pass
1414

1515

16+
def test_point_equality():
17+
p1 = Point(1, 1, 1)
18+
p2 = Point(1, 1, 1)
19+
p3 = Point(0, 0, 0)
20+
assert p1 == p2
21+
assert not (p1 != p2)
22+
assert p1 != p3
23+
assert not (p1 == p3)
24+
25+
1626
def test_point_inplace_operators():
1727
pass
1828

tests/compas/geometry/test_transformations/test_transformation.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,40 @@ def test_list():
108108
assert T.list == [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
109109

110110

111-
def concatenate():
111+
def test_concatenated():
112112
trans1 = [1, 2, 3]
113113
angle1 = [-2.142, 1.141, -0.142]
114114
T1 = Translation.from_vector(trans1)
115115
R1 = Rotation.from_euler_angles(angle1)
116-
M1 = T1.concatenate(R1)
116+
M1 = T1.concatenated(R1)
117117
assert allclose(M1, T1 * R1)
118+
119+
120+
def test___repr__():
121+
trans = [1, 2, 3]
122+
axes = [-2.142, 1.141, -0.142]
123+
angle = 0.7854
124+
R = Rotation.from_axis_and_angle(axes, angle, point=trans)
125+
assert R == eval(repr(R))
126+
127+
128+
def test___str__():
129+
s = '[[ 0.9345, -0.0798, 0.3469, -0.8157],\n' + \
130+
' [ -0.1624, 0.7716, 0.6150, -1.2258],\n' + \
131+
' [ -0.3168, -0.6311, 0.7081, 2.4546],\n' + \
132+
' [ 0.0000, 0.0000, 0.0000, 1.0000]]\n'
133+
trans = [1, 2, 3]
134+
axes = [-2.142, 1.141, -0.142]
135+
angle = 0.7854
136+
R = Rotation.from_axis_and_angle(axes, angle, point=trans)
137+
assert s == str(R)
138+
139+
140+
def test___eq__():
141+
i1 = Transformation()
142+
i2 = Transformation()
143+
t = Translation.from_vector([1, 0, 0])
144+
assert i1 == i2
145+
assert not (i1 != i2)
146+
assert i1 != t
147+
assert not (i1 == t)

0 commit comments

Comments
 (0)