Skip to content

Conversation

@arpastrana
Copy link
Contributor

No description provided.

@arpastrana arpastrana mentioned this pull request Feb 26, 2019
"""
point = transform_points([self.point], matrix)
normal = transform_vectors([self.normal], matrix)
point = transform_points([self.point], matrix)[0]
Copy link
Member

@gonzalocasas gonzalocasas Feb 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a bug? Does it fail without this change? Maybe you could add a little unit test for it (especially if it was failing before and your change fixes it)..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I just see the linked issue ;)

@arpastrana
Copy link
Contributor Author

Here's a small unit-test. Without the try-except, it fails with TypeError: float() argument must be a string or a number, not 'list'. Moreover, I noticed the slicing proposed here in #261 is already implemented in line 554 of _primitives/vector.py

import math
from compas.geometry import Frame
from compas.geometry import Plane
from compas.geometry import Rotation
from compas.geometry import Vector

vector = Vector(0, 0, 1)
plane = Plane([0, 0, 0], vector)
frame = Frame.worldXY()

for angle in range(0, 90, 15):
	print('---')
	rot = Rotation.from_axis_and_angle([1, 0, 0], math.radians(angle))
	
	vector.transform(rot)
	print(vector)

	frame.transform(rot)
	print(frame)

	try:
		plane.transform(rot)
		print(plane)
	except TypeError:
		print('something went wrong!')

@romanarust
Copy link
Member

There is actually an incosistency in the plane.transform() in comparison to transform functions in other primitives. They all perform the Transform through their attributes. So rather than point = transform_points([self.point], matrix)[0] and then overwriting, it should be self.point.transform(transformation) and self.vector.transform(transformation) (passing an Transformation class). I am actually about to fix this inconsistency amongst other stuff in the branch feature/geometry_primitives_update, which is soon to merge. But in the meantime I'll merge this one.

https://github.com/compas-dev/compas/blob/feature/geometry_primitives_update/src/compas/geometry/_primitives/plane.py

@romanarust romanarust merged commit 3bb81ac into compas-dev:master Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants