Skip to content

Scalar multiplication for shapes #41

Open
@bdice

Description

@bdice

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__ for shape * 1.5
  • __matmul__ for shape @ three_by_three_transformation_matrix
  • __truediv__ for shape / 1.5

Other things like negation (multiply all vertex vectors by -1), vector addition to all vertices, etc. are possible if desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions