-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scalar multiplication for shapes #41
Comments
Related: the Sketch (not tested):
|
The volume is already settable. The other operators are good ideas, we should probably first have a broader discussion implementing operators for shapes before jumping in and implementing them to make sure that we're covering use-cases. This discussion would impact #23. |
Are there any plans to support shape orientation and rotation operations in the future? |
@vasudevanv You might be interested in the rowan package: https://rowan.readthedocs.io/en/latest/ The rowan library has a variety of routines for dealing with quaternions, including 3D rotations and point-cloud registration. If you want more information or an example, let us know what you need and we can help! |
@vasudevanv A simple example of rotating the vertices of a ConvexPolyhedron can be found here: https://coxeter.readthedocs.io/en/latest/examples/InertiaTensors.html?highlight=rowan |
@bdice Thank you so much. That was exactly what I was looking for. |
Feature description
I would like to be able to multiply a polyhedron or polygon by a scaling factor, which would apply as a scalar multiplication to its vertex vectors. Similarly, radii of spheres or spheropolytopes would scale linearly.
Proposed solution
Implement
__mul__
, etc: https://docs.python.org/3/library/operator.html#operator.__mul__The operations should return a new shape instance.
Candidates:
__mul__
forshape * 1.5
__matmul__
forshape @ three_by_three_transformation_matrix
__truediv__
forshape / 1.5
Other things like negation (multiply all vertex vectors by -1), vector addition to all vertices, etc. are possible if desired.
The text was updated successfully, but these errors were encountered: