A Python package for three-dimensional geometry.
Run
python -m pip install -e ".[dev]"
to install pygeo and all dependencies required for local development.
Run
pytest tests
to run all the tests for pygeo.
-
Implement the missing
Rayclass. A ray may be represented as its origin and a direction.- Implement an
__init__method that takes the origin and direction as argument and stores them as attributes on the instance. - Implement a
__repr__method. - Implement an
__eq__method that works by comparing both the origin and direction of the other ray. Provide tests for this method.
- Implement an
-
Implement the missing
Sphereclass. A sphere may be represented by its center and a radius.- Implement an
__init__method that takes the center and radius as argument and stores them as attributes on the instance. - Implement a
__repr__method. - Implement an
__eq__method that works by comparing both the center and radius of the other sphere. Provide tests for this method.
- Implement an
-
Implement the missing
_intersect_ray_and_spherefunction. You may follow this article, but keep in mind that for a ray the parameterdmentioned in the article must be larger or equal to zero. Provide tests for this method.
As an optional extra exercise, implement
- the missing
Triangleclass, - the missing
_intersect_ray_and_trianglefunction and accompanying tests, and - the missing
intersectthat calls either_intersect_ray_and_sphereor_intersect_ray_and_triangledepending on the arguments.