### Install Pre-commit Hooks Source: https://github.com/jan-mue/geometer/blob/main/CONTRIBUTING.md Install pre-commit hooks to automatically format code and check for linting issues. ```bash pre-commit install ``` -------------------------------- ### Verify Geometer Installation Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/README.md Shows how to verify the Geometer installation by checking its version using a Python one-liner. ```bash # Verify installation python -c "import geometer; print(geometer.__version__)" ``` -------------------------------- ### Install Geometer Package Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/README.md Provides the command to install the Geometer library from PyPI using pip. ```bash # Install from PyPI pip install geometer ``` -------------------------------- ### Cone Constructor Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Shows how to instantiate a Cone object with specified vertex, base center, and radius. Imports Cone and Point from geometer. ```python from geometer import Cone, Point cone = Cone(vertex=Point(0, 0, 0), base_center=Point(0, 0, 2), radius=1) ``` -------------------------------- ### Create Tetrahedron and Get Volume Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/shapes.md Instantiate a Simplex by providing its vertices. This example creates a 3-simplex (tetrahedron) and prints its volume. ```python from geometer import Simplex, Point # Tetrahedron tet = Simplex( Point(0, 0, 0), Point(1, 0, 0), Point(0, 1, 0), Point(0, 0, 1) ) print(tet.volume) ``` -------------------------------- ### Sphere Properties Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Demonstrates how to create a Sphere object and access its volume and area properties. Requires importing Sphere and Point from geometer. ```python from geometer import Sphere, Point s = Sphere(center=Point(0, 0, 0), radius=2) print(s.volume) print(s.area) ``` -------------------------------- ### Custom Tolerance Workflow Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/configuration.md Provides a practical example of defining and using custom tolerance values for specific geometric checks. It demonstrates creating functions for strict and robust incidence testing based on problem-specific tolerance needs. ```python from geometer import Point, Line from geometer.base import EQ_TOL_ABS # Define problem-specific tolerance STRICT_TOL = 1e-12 LOOSE_TOL = 1e-4 # Strict geometric invariant check def check_incidence_strict(point, line): """Check incidence with high precision.""" return line.contains(point, tol=STRICT_TOL) # Robust incidence check (for noisy data) def check_incidence_robust(point, line): """Check incidence with loose tolerance.""" return line.contains(point, tol=LOOSE_TOL) # Usage line = Line(1, 0, -1) point = Point(1, 1e-12) strict_result = check_incidence_strict(point, line) loose_result = check_incidence_robust(point, line) print(f"Strict: {strict_result}, Loose: {loose_result}") ``` -------------------------------- ### Install Geometer via pip Source: https://github.com/jan-mue/geometer/blob/main/docs/index.md Use this command to install the geometer package from the Python Package Index. ```default pip install geometer ``` -------------------------------- ### Cylinder Constructor Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Illustrates the creation of a Cylinder object with a given center, direction, and radius. Requires importing Cylinder and Point from geometer. ```python from geometer import Cylinder, Point cyl = Cylinder(center=Point(0, 0, 0), direction=Point(0, 0, 1), radius=0.5) ``` -------------------------------- ### Catch GeometryException Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/errors.md Demonstrates how to catch a general GeometryException. This is useful for handling any geometry-related error gracefully. ```python from geometer import Point, Line, join from geometer.exceptions import GeometryException try: p1 = Point(0, 0) p2 = Point(1, 1) line = join(p1, p2) except GeometryException as e: print(f"Geometry error: {e}") ``` -------------------------------- ### Example Usage of EQ_TOL_REL Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/configuration.md Demonstrates using the relative tolerance constant in a numpy.allclose comparison. ```python from geometer.base import EQ_TOL_REL import numpy as np # Compare with relative tolerance result = np.allclose(a, b, rtol=EQ_TOL_REL, atol=EQ_TOL_ABS) ``` -------------------------------- ### Example Usage of EQ_TOL_ABS Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/configuration.md Shows how to use the absolute tolerance constant to check if a point is approximately at infinity. ```python from geometer.base import EQ_TOL_ABS from geometer import Point # Check if point is at infinity (last coordinate near 0) p = Point(1, 2, 1e-9) if np.isclose(p.array[-1], 0, atol=EQ_TOL_ABS): print("Point is approximately at infinity") ``` -------------------------------- ### Point, Line, Plane Classes and join/meet Functions Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/CONTENTS.txt Documentation for Point, Line, and Plane classes, including their associated join and meet functions. This section details their signatures, parameters, return types, and usage examples. ```APIDOC ## Point, Line, Plane Classes and join/meet Functions ### Description This section covers the core geometric entities: Point, Line, and Plane. It details their construction, properties, and fundamental operations like `join` (union) and `meet` (intersection). ### Classes - **Point**: Represents a point in geometric space. - **Line**: Represents a line in geometric space. - **Plane**: Represents a plane in geometric space. ### Functions - **join(entity1, entity2, ...)**: Computes the smallest geometric entity containing all input entities. - **meet(entity1, entity2, ...)**: Computes the largest geometric entity contained within all input entities. ### Usage Examples ```python from geometer import Point, Line, Plane p1 = Point(1, 2, 3) p2 = Point(4, 5, 6) line = Line.from_points(p1, p2) plane = Plane.from_points(p1, p2, Point(7, 8, 9)) # Example of join (implicitly handled by constructors or specific methods) # Example of meet (implicitly handled by constructors or specific methods) ``` ### See Also - [Global Reference - types.md](/geometer/types.md) for type definitions. - [API Reference - operators.md](/geometer/operators.md) for related geometric operations. ``` -------------------------------- ### Create Unit Cube and Get Volume and Area Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/shapes.md Instantiate a Cuboid using three vectors originating from a base corner point. Access its volume and surface area properties. ```python from geometer import Cuboid, Point # Unit cube cube = Cuboid( Point(0, 0, 0), Point(1, 0, 0), Point(0, 1, 0), Point(0, 0, 1) ) print(cube.volume) # 1.0 print(cube.area) # 6.0 ``` -------------------------------- ### Create Regular Hexagon and Get Properties Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/shapes.md Instantiate a RegularPolygon with a center, radius, and number of sides (n=6 for a hexagon). Access its area and radius properties. ```python from geometer import RegularPolygon, Point import numpy as np # Regular hexagon hexagon = RegularPolygon(Point(0, 0), 1, 6) print(hexagon.area) print(hexagon.radius) ``` -------------------------------- ### Catch NotCoplanar Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/errors.md Shows how to catch the NotCoplanar exception. This is relevant for 3D operations involving lines or points that should lie on the same plane but do not. ```python from geometer import Point, Line, join from geometer.exceptions import NotCoplanar # Two skew lines in 3D (don't intersect, not parallel) p1 = Point(0, 0, 0) p2 = Point(1, 0, 0) p3 = Point(0, 1, 1) p4 = Point(1, 1, 1) l1 = join(p1, p2) l2 = join(p3, p4) try: # Try to intersect non-coplanar lines intersection = l1.meet(l2) except NotCoplanar as e: print(f"Error: {e}") # Output: Error: The given lines are not all coplanar. ``` -------------------------------- ### Create 3D points and lines Source: https://github.com/jan-mue/geometer/blob/main/docs/quickstart.md Initialize points and lines in three-dimensional space. ```python p1 = Point(1, 1, 0) p2 = Point(2, 1, 0) p3 = Point(3, 4, 0) l = Line(p1, p2) ``` -------------------------------- ### Create 2D points and lines Source: https://github.com/jan-mue/geometer/blob/main/docs/quickstart.md Initialize points and lines using coordinates or base points. ```python from geometer import * p = Point(2, 4) q = Point(3, 5) l = Line(p, q) m = Line(0, 1, 0) ``` -------------------------------- ### Create and Use 2D Points Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/README.md Demonstrates how to create 2D points, join them to form a line, and test for point containment on the line. ```python from geometer import Point, Line # Create 2D points p = Point(1, 2) q = Point(3, 4) # Join to create a line line = p.join(q) # Test containment if line.contains(Point(2, 3)): print("Point is on line") ``` -------------------------------- ### Run All Pre-commit Hooks Source: https://github.com/jan-mue/geometer/blob/main/CONTRIBUTING.md Manually run all configured pre-commit hooks across all files for formatting and linting. ```bash pre-commit run --all-files ``` -------------------------------- ### Work with Conics Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/README.md Demonstrates creating a conic from five points, finding its intersection with a line, and calculating the tangent at a specific point. ```python from geometer import Point, Conic, Line # Conic through 5 points c = Conic.from_points( Point(0, 0), Point(1, 0), Point(0, 1), Point(1, 1), Point(2, 2) ) # Find intersection with line line = Line(0, 1, 0) intersections = c.intersect(line) # Get tangent at a point tangent = c.tangent(Point(0, 0)) ``` -------------------------------- ### Catch NotCollinear Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/errors.md Demonstrates catching the NotCollinear exception. This is useful when performing operations like cross ratio calculations that require collinear points. ```python from geometer import Point, crossratio from geometer.exceptions import NotCollinear p1 = Point(0, 0) p2 = Point(1, 0) p3 = Point(0, 1) # Not on the same line as p1 and p2 p4 = Point(1, 1) try: cr = crossratio(p1, p2, p3, p4) except NotCollinear as e: print(f"Error: {e}") # Output: Error: The points are not collinear: [...] ``` -------------------------------- ### Sync Dependencies with uv Source: https://github.com/jan-mue/geometer/blob/main/CONTRIBUTING.md Use uv to synchronize project dependencies based on pyproject.toml. ```bash uv sync ``` -------------------------------- ### Check if Lines or Planes are Perpendicular Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/operators.md Tests if two lines or two planes are perpendicular to each other. The example shows checking perpendicularity between two lines in a 2D space. ```python from geometer import Line, is_perpendicular l1 = Line(1, 0, 0) # x = 0 l2 = Line(0, 1, 0) # y = 0 result = is_perpendicular(l1, l2) print(result) # True ``` -------------------------------- ### Handle Polygons and Polytopes Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/README.md Shows how to create a triangle, check its area, and determine if a point is contained within it using Geometer's shape operations. ```python from geometer import Triangle, Point # Create a triangle t = Triangle(Point(0, 0), Point(1, 0), Point(0, 1)) # Check area print(f"Area: {t.area}") # Check if point is inside if t.contains(Point(0.2, 0.2)): print("Point is inside triangle") ``` -------------------------------- ### Check if Points are Cocircular Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/operators.md Verifies if four given points lie on the same circle. This example demonstrates the usage of the `is_cocircular` function with four points on a unit circle. ```python from geometer import Point, is_cocircular import numpy as np # Four points on a circle centered at origin with radius 1 p1 = Point(1, 0) p2 = Point(0, 1) p3 = Point(-1, 0) p4 = Point(0, -1) result = is_cocircular(p1, p2, p3, p4) print(result) # True ``` -------------------------------- ### Create and Join Points to Form a Line Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/point.md Demonstrates how to create two Point objects and use the 'join' method to form a Line object. This is useful for defining lines in 2D projective space. ```python from geometer import Point, Line # Create two points and join them to form a line p = Point(0, 0) q = Point(1, 1) line = p.join(q) print(line) # Line in 2D space through p and q ``` -------------------------------- ### Catch TensorComputationError Example Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/errors.md Shows how to catch a TensorComputationError. Use this when performing complex tensor operations that might fail due to numerical instability or dimension mismatches. ```python from geometer.exceptions import TensorComputationError try: # Some complex tensor operation result = obj1 * obj2 except TensorComputationError as e: print(f"Tensor computation failed: {e}") ``` -------------------------------- ### Handling IncompatibleShapeError for PointCollection Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/errors.md This example demonstrates how to catch and handle `IncompatibleShapeError` when creating a `PointCollection` with an incorrect tensor shape. Always validate array ranks and collection structures. ```python from geometer import PointCollection import numpy as np # Create points with wrong collection shape try: pc = PointCollection(np.zeros((2, 2, 3))) # Wrong structure except IncompatibleShapeError as e: print(f"Error: {e}") ``` -------------------------------- ### Clone Geometer Repository Source: https://github.com/jan-mue/geometer/blob/main/CONTRIBUTING.md Clone your forked repository to your local machine and navigate into the project directory. ```bash git clone https://github.com/your-username/geometer.git cd geometer ``` -------------------------------- ### Check if Points or Lines are Coplanar Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/operators.md Determines if a set of points or lines lie on the same plane (or are collinear in 2D, or concurrent). This example checks coplanarity of three points and non-coplanarity of four points. ```python from geometer import Point, is_coplanar p1 = Point(0, 0, 0) p2 = Point(1, 0, 0) p3 = Point(0, 1, 0) p4 = Point(0, 0, 1) result = is_coplanar(p1, p2, p3) # True (3 points define a plane) result = is_coplanar(p1, p2, p3, p4) # False (4 points not coplanar) ``` -------------------------------- ### Create and project planes Source: https://github.com/jan-mue/geometer/blob/main/docs/quickstart.md Construct a plane from a line and a point, then project a point onto it. ```python A = join(l, p3) A.project(Point(3, 4, 5)) ``` -------------------------------- ### Polygon Constructor and contains Method Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/shapes.md Shows how to create a Polygon and test if a Point is inside it. Requires importing Polygon and Point from geometer. ```python from geometer import Polygon, Point poly = Polygon(Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)) p = Point(0.5, 0.5) if poly.contains(p): print("Point is inside polygon") ``` -------------------------------- ### Configuration and Numerical Tolerances Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/CONTENTS.txt Information on numerical tolerances, configuration constants, and their safe ranges for use within the Geometer library. ```APIDOC ## Configuration and Numerical Tolerances ### Description This section details the configuration constants and numerical tolerances used within the Geometer library. Understanding these values is crucial for managing precision in geometric computations and ensuring robust results. ### Numerical Tolerances - **Default Tolerance**: The standard epsilon value used for floating-point comparisons (e.g., checking for equality, collinearity, coplanarity). - **Safe Ranges**: Guidance on the recommended ranges for input values and the implications of exceeding them. - **Specific Tolerances**: Tolerances for specific operations like angle calculations, distance computations, etc. ### Configuration Constants - **Max Iterations**: For iterative algorithms. - **Precision Settings**: Options to control the precision of calculations. ### Usage Users can often access and potentially modify these tolerances to suit their specific application needs, though it is recommended to use the default values unless a clear need arises. ```python import geometer # Accessing default tolerance (example attribute, actual may vary) # print(f"Default tolerance: {geometer.config.TOLERANCE}") # Example of using a custom tolerance in a function if supported # result = some_geometer_function(..., tolerance=1e-9) ``` ### Best Practices - Be aware of the limitations of floating-point arithmetic. - Adjust tolerances cautiously, as overly strict values can lead to false negatives, while overly lenient values can lead to false positives. ### See Also - [Global Reference - errors.md](/geometer/errors.md) for error handling strategies. ``` -------------------------------- ### Run Tests with pytest Source: https://github.com/jan-mue/geometer/blob/main/CONTRIBUTING.md Execute the test suite using pytest, managed by uv. ```bash uv run pytest ``` -------------------------------- ### Tensor Class Methods and Properties Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Documentation for methods and properties of the Tensor class. ```APIDOC #### *classmethod* from_tensor(tensor, **kwargs) Construct an object from another tensor. If the tensor has no free indices, an object of type TensorT is returned. By default the array in the tensor is not copied. * **Parameters:** * **tensor** ([*Tensor*](#geometer.base.Tensor)) – A tensor to use for the new tensor. * ** **kwargs** (*Unpack* *[**NDArrayParameters* *]*) – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array. * **Returns:** A new tensor. * **Return type:** Self | TensorT #### *property* size *: npt.NDArray[np.int_]* The number of tensors in the tensor collection, i.e. the product of the size of all collection axes. ``` -------------------------------- ### Initialize Cone Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Initializes a Cone object, a quadric forming a circular double cone in 3D. Requires vertex, base_center, and radius. Additional keyword arguments are passed to the Quadric constructor. ```python Cone(vertex=Point(0, 0, 0), base_center=Point(0, 0, 1), radius=1, **kwargs) ``` -------------------------------- ### Apply Geometric Transformations Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/README.md Shows how to apply rotation, translation, and composed transformations to a 2D point using the Geometer library. ```python from geometer import Point, rotation, translation import numpy as np p = Point(1, 0) # Rotate 45 degrees t = rotation(np.pi / 4) rotated = t * p # Translate by (1, 1) t = translation(1, 1) translated = t * p # Compose transformations t_composed = translation(1, 1) * rotation(np.pi / 4) result = t_composed * p ``` -------------------------------- ### Exception Classes and Error Handling Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/CONTENTS.txt Detailed documentation of all exception classes, including their trigger conditions and recommended recovery strategies. ```APIDOC ## Exception Classes and Error Handling ### Description This section lists and describes all custom exception classes defined in the Geometer library. It provides information on when each exception is raised and offers guidance on how to handle or recover from these errors. ### Base Exception - **GeometryException**: The base class for all Geometer-specific exceptions. ### Specific Exception Types - **TensorComputationError**: Raised when an error occurs during tensor computations. - **NotCollinear**: Raised when a geometric operation requires collinearity, but the input entities are not collinear. - **NotCoplanar**: Raised when a geometric operation requires coplanarity, but the input entities are not coplanar. - **NotConcurrent**: Raised when a geometric operation requires concurrency, but the input entities are not concurrent. - **NoIncidence**: Raised when an expected geometric incidence does not exist. - **IncidenceError**: General error related to geometric incidences. - **LinearDependenceError**: Raised when linear dependence issues are encountered. - **NotReducible**: Raised when an entity cannot be reduced as expected. - **IncompatibleShapeError**: Raised when operations are attempted on incompatible geometric shapes. ### Usage It is recommended to catch specific exceptions to handle errors gracefully. ```python from geometer import Point, Line, GeometryException try: p1 = Point(1, 1) p2 = Point(2, 2) line = Line.from_points(p1, p2) # An operation that might raise an error # e.g., trying to find intersection of parallel lines if not handled except NotCollinear as e: print(f"Error: Input points are not collinear. {e}") except GeometryException as e: print(f"A Geometer error occurred: {e}") except Exception as e: print(f"An unexpected error occurred: {e}") ``` ### See Also - [Global Reference - configuration.md](/geometer/configuration.md) for numerical tolerance guidance. ``` -------------------------------- ### Triangle Properties Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/shapes.md Illustrates creating a Triangle and accessing its area and circumcenter properties. Requires importing Triangle and Point from geometer. ```python from geometer import Triangle, Point t = Triangle(Point(0, 0), Point(1, 0), Point(0, 1)) print(t.area) print(t.circumcenter) ``` -------------------------------- ### Point Methods Source: https://github.com/jan-mue/geometer/blob/main/docs/source/modules.md Methods for the Point class, specifically the `join()` operation. ```APIDOC ## Point Methods ### Description Provides methods for Point objects, including the `join()` operation. ### Methods - `join(other)`: Computes the join of the Point with another geometric object. ``` -------------------------------- ### 2D Point and Line Operations in Geometer Source: https://github.com/jan-mue/geometer/blob/main/README.md Demonstrates basic operations with Points and Lines in 2D, including meet, parallel, and perpendicular lines. ```Python from geometer import * import numpy as np # Meet and Join operations p = Point(2, 4) q = Point(3, 5) l = Line(p, q) m = Line(0, 1, 0) l.meet(m) # Point(-2, 0) ``` ```Python # Parallel and perpendicular lines m = l.parallel(through=Point(1, 1)) n = l.perpendicular(through=Point(1, 1)) is_perpendicular(m, n) # True ``` -------------------------------- ### PolytopeTensor Constructor Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Initialize a polytope in arbitrary dimension. ```APIDOC ## class geometer.shapes.PolytopeTensor ### Description A class representing polytopes in arbitrary dimension. A (n+1)-polytope is a collection of n-polytopes that have some (n-1)-polytopes in common. ### Parameters - **args** (Tensor | npt.ArrayLike) - Required - The polytopes defining the facets of the polytope. - **pdim** (int) - Optional - The dimension of the polytope. Default is 0. - **kwargs** (Unpack[NDArrayParameters]) - Optional - Additional keyword arguments for the constructor of the numpy array. ``` -------------------------------- ### Create Sphere Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Initializes a Sphere object with a specified center and radius. Supports spheres in any dimension. Default values are used if not provided. ```python from geometer import Sphere, Point # Example usage for Sphere constructor would go here, but is not provided in the source. ``` -------------------------------- ### Line Constructor Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/point.md Initializes a Line object. It can be constructed using two Point objects or line coordinates. ```APIDOC ## Line Constructor ### Description Initializes a Line object. It can be constructed using two Point objects or line coordinates. ### Parameters - ***args** (Tensor | ArrayLike) - Required - Either two Point objects, or line coordinates. For 2D: 3 coordinates [a, b, c] representing ax + by + c = 0. - ****kwargs** (dict) - Required - Additional numpy array constructor arguments. ### Returns A Line object. ``` -------------------------------- ### Transformations to Power (Composition/Inverse) Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/transformation.md Raises a transformation to an integer power. Positive powers represent repeated composition (e.g., t**2 is t applied twice). Negative powers compute the inverse transformation (e.g., t**-1 is the inverse of t). ```python t = rotation(np.pi / 4) t_squared = t ** 2 # 90-degree rotation t_inv = t ** -1 # Inverse transformation ``` -------------------------------- ### Initialize Circle Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Initializes a Circle object in 2D. Accepts a center Point and radius. Additional keyword arguments are passed to the numpy array constructor. ```python Circle(center=Point(0, 0), radius=1, **kwargs) ``` -------------------------------- ### Segment Constructor and contains Method Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/shapes.md Demonstrates creating a Segment and checking if a Point lies on it. Requires importing Segment and Point from geometer. ```python from geometer import Segment, Point s = Segment(Point(0, 0), Point(2, 2)) p = Point(1, 1) if s.contains(p): print("Point is on segment") ``` -------------------------------- ### Create Circle Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Initializes a Circle object with a specified center and radius. Default values are used if not provided. ```python from geometer import Circle, Point # Example usage for Circle constructor would go here, but is not provided in the source. ``` -------------------------------- ### Circle Constructor Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Constructs a circle in 2D. ```APIDOC ## Circle ### Description A circle in 2D. ### Constructor Signature ```python Circle(center: Point = Point(0, 0), radius: float = 1, **kwargs) -> Circle ``` ### Parameters #### Path Parameters - **center** (Point) - Optional - Center of circle. Defaults to Point(0, 0). - **radius** (float) - Optional - Radius. Defaults to 1. - **kwargs** (dict) - Optional - Additional numpy array arguments. ### Properties - **center** (Point) - Center point of circle. - **radius** (float) - Radius value. - **area** (float) - Area (π·r²). - **lie_coordinates** (ndarray) - Normalized Lie coordinates in R⁴. ### Example ```python from geometer import Circle, Point c1 = Circle(Point(0, 0), 1) c2 = Circle(Point(1, 0), 1) ``` ``` -------------------------------- ### RegularPolygon Constructor Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Construct a regular polygon from a radius and a center point. ```APIDOC ## class geometer.shapes.RegularPolygon ### Description A class that can be used to construct regular polygon from a radius and a center point. ### Parameters - **center** (Point) - Required - The center of the polygon. - **radius** (float) - Required - The distance from the center to the vertices of the polygon. - **n** (int) - Required - The number of vertices of the regular polygon. - **axis** (Point | None) - Optional - If constructed in higher-dimensional spaces, an axis vector is required to orient the polygon. - **kwargs** (Unpack[NDArrayParameters]) - Optional - Additional keyword arguments for the constructor of the numpy array. ``` -------------------------------- ### Accessing and Using Tolerance Constants Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/configuration.md Shows how to import and utilize the predefined absolute and relative tolerance constants (`EQ_TOL_ABS`, `EQ_TOL_REL`) directly in comparisons or function calls. These constants represent standard values used within the library. ```python from geometer.base import EQ_TOL_ABS, EQ_TOL_REL # Use in comparisons import numpy as np result = np.allclose(a, b, atol=EQ_TOL_ABS, rtol=EQ_TOL_REL) ``` ```python from geometer import Point, Line from geometer.base import EQ_TOL_ABS line = Line(1, 0, 0) point = Point(0, 0) # Use constant as default or override result = line.contains(point, tol=EQ_TOL_ABS * 100) ``` -------------------------------- ### Commit Changes Source: https://github.com/jan-mue/geometer/blob/main/CONTRIBUTING.md Stage all changes and commit them with a descriptive message following conventional commits. ```bash git add . git commit -m "feat: add new feature" ``` -------------------------------- ### Create a Line from coordinates Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/point.md Instantiate a Line object using its coefficients [a, b, c] for the equation ax + by + c = 0. ```python from geometer import Line, Point l = Line(1, 0, -2) # x - 2 = 0 m = Line(0, 1, -3) # y - 3 = 0 intersection = l.meet(m) # Point(2, 3) ``` -------------------------------- ### Geometer Library Structure Overview Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/README.md This section outlines the organizational structure of the geometer library's documentation, detailing the core API reference modules and global reference sections. ```markdown # Geometer Technical Reference Complete API reference documentation for the **geometer** library - a Python geometry library using projective geometry and numpy. **Library Version:** Latest **Python Support:** 3.10+ **Repository:** https://github.com/jan-mue/geometer --- ## Documentation Structure ### Core API Reference (`api-reference/`) The API reference is organized by module, documenting all exported functions, classes, and methods. #### [Point Module](api-reference/point.md) Points, lines, and planes in projective space. - **Classes:** Point, PointCollection, Line, LineCollection, Plane, PlaneCollection - **Functions:** join(), meet() - **Special Points:** I, J, infty, infty_plane, infty_hyperplane() - **Coverage:** 1-dimensional subspaces, intersection/union operations, affine operations #### [Transformation Module](api-reference/transformation.md) Projective transformations for geometric objects. - **Classes:** Transformation, TransformationCollection - **Functions:** identity(), affine_transform(), rotation(), translation(), scaling(), reflection() - **Methods:** from_points(), apply(), inverse() - **Coverage:** Matrix-based transformations, composition, specialized transforms #### [Operators Module](api-reference/operators.md) Geometric computations and measurements. - **Functions:** angle(), angle_bisectors(), crossratio(), harmonic_set(), dist() - **Tests:** is_perpendicular(), is_cocircular(), is_coplanar(), is_collinear(), is_concurrent() - **Coverage:** Angles, distances, cross ratios, incidence tests #### [Curve Module](api-reference/curve.md) Quadrics and conic sections (2nd-degree algebraic surfaces). - **Classes:** Quadric, QuadricCollection, Conic, Ellipse, Circle, Sphere, Cone, Cylinder - **Methods:** from_points(), from_lines(), from_tangent(), from_foci(), intersect(), tangent(), polar() - **Coverage:** Conics in 2D, quadrics in higher dimensions, special surfaces #### [Shapes Module](api-reference/shapes.md) Geometric shapes and polytopes. - **Classes:** Segment, SegmentCollection, Polygon, PolygonCollection, Triangle, Rectangle, RegularPolygon, Simplex, Polyhedron, Cuboid - **Methods:** contains(), intersect(), vertices, edges, area, volume - **Coverage:** Points, segments, polygons, polyhedra, area/volume calculations --- ## Global Reference ### [Type Definitions](types.md) Named types and type aliases used throughout the library. - **Tensor Types:** PointTensor, LineTensor, PlaneTensor, SubspaceTensor - **Transformation Types:** TransformationTensor, TransformationCollection - **Quadric Types:** QuadricTensor, Conic, etc. - **Polytope Types:** PolytopeTensor and all shape classes - **Base Types:** Tensor, TensorCollection - **Type Variables:** T, SubspaceT, PolytopeT - **Exception Types:** GeometryException and all custom exceptions ### [Error Catalog](errors.md) All exceptions and error conditions. - **Exception Hierarchy:** Complete class diagram - **Error Types:** 8 custom exception classes with trigger conditions - **Prevention Checklist:** How to avoid each error type - **Best Practices:** Exception handling patterns ### [Configuration & Constants](configuration.md) Global configuration values and numerical tolerances. - **Tolerance Constants:** EQ_TOL_REL (1e-15), EQ_TOL_ABS (1e-8) - **Function Parameters:** tol, rtol, atol parameters across library - **Numerical Stability:** Guidance on floating-point precision - **Safe Ranges:** Recommended tolerance values for different scenarios --- ## Quick Navigation ### By Use Case **Working with Points and Lines:** → See [Point Module](api-reference/point.md) **Transforming Objects:** → See [Transformation Module](api-reference/transformation.md) **Measuring Angles and Distances:** → See [Operators Module](api-reference/operators.md) **Working with Curves and Quadrics:** → See [Curve Module](api-reference/curve.md) **Creating and Analyzing Shapes:** → See [Shapes Module](api-reference/shapes.md) **Understanding Error Messages:** → See [Error Catalog](errors.md) **Type System and Generics:** → See [Type Definitions](types.md) **Adjusting Numerical Precision:** → See [Configuration & Constants](configuration.md) --- ## Class Hierarchy ``` Point (single point in projective space) ├─ PointCollection (multiple points) Line (single line) ├─ LineCollection (multiple lines) Plane (single hyperplane) ├─ PlaneCollection (multiple planes) Transformation (single transformation matrix) ├─ TransformationCollection (multiple transformations) Quadric (single quadric surface) ├─ Conic (2D conic section) │ ├─ Ellipse │ ├─ Circle ├─ Sphere ├─ Cone ├─ Cylinder Segment (line segment) ├─ SegmentCollection Polygon (polygonal region) ├─ Triangle ├─ Rectangle ├─ RegularPolygon ├─ PolygonCollection Polyhedron (3D polytope) └─ Cuboid ``` --- ## Function Index ``` -------------------------------- ### from_points_and_conics Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Constructs a projective transformation from two conics and the image of pairs of 3 points on the conics. ```APIDOC ## from_points_and_conics ### Description Constructs a projective transformation from two conics and the image of pairs of 3 points on the conics. ### Parameters - **points1** (Sequence[Point]) - Required - Source points on conic1. - **points2** (Sequence[Point]) - Required - Target points on conic2. - **conic1** (Conic) - Required - Source quadric. - **conic2** (Conic) - Required - Target quadric. ### Response - **TransformationTensor** - The transformation that maps the points to each other and the conic to the other conic. ``` -------------------------------- ### Apply projective transformations Source: https://github.com/jan-mue/geometer/blob/main/docs/quickstart.md Create and apply rotation, translation, or custom matrix transformations. ```python t1 = translation(0, -1) t2 = rotation(-np.pi) t3 = Transformation([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) t1*t2*p ``` -------------------------------- ### Detecting Points at Infinity Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/configuration.md Demonstrates how to check if a Point is at infinity by examining its last coordinate against a tolerance. This is useful for handling projective geometry concepts. ```python from geometer import Point import numpy as np # Points at infinity have last coordinate near EQ_TOL_ABS p_inf = Point(1, 2, 1e-10) print(p_inf.isinf) # True if last coordinate is near 0 p_finite = Point(1, 2, 1) print(p_finite.isinf) # False ``` -------------------------------- ### Create Reflection Transformation Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/transformation.md Returns a reflection transformation across a specified line (2D) or hyperplane (nD). ```python from geometer import reflection, Line, Point # Reflect across the line y = x line = Line(1, -1, 0) # x - y = 0 t = reflection(line) p = Point(1, 0) reflected = t * p # Point(0, 1) ``` -------------------------------- ### Sphere Constructor Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Constructs a sphere in any dimension. ```APIDOC ## Sphere ### Description A sphere in any dimension. ### Constructor Signature ```python Sphere(center: Point = Point(0, 0, 0), radius: float = 1, **kwargs) -> Sphere ``` ### Parameters #### Path Parameters - **center** (Point) - Optional - Center of sphere. Defaults to Point(0, 0, 0). - **radius** (float) - Optional - Radius. Defaults to 1. - **kwargs** (dict) - Optional - Additional numpy array arguments. ``` -------------------------------- ### Create Affine Transformation Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/transformation.md Constructs a projective transformation from an affine transformation (matrix + translation). Use an identity matrix if no matrix is provided. ```python from geometer import affine_transform import numpy as np # 2D scaling by 2 with translation (1, 1) t = affine_transform( matrix=np.array([[2, 0], [0, 2]]), offset=[1, 1] ) p = affine_transform(offset=[1, 0]) # Translation only ``` -------------------------------- ### Perform meet and join operations Source: https://github.com/jan-mue/geometer/blob/main/docs/quickstart.md Calculate intersections and lines connecting points. ```python l = join(p, q) r = meet(l, m) ``` -------------------------------- ### Transformation Classes and Builder Functions Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/CONTENTS.txt Details on Transformation classes and builder functions used for geometric transformations such as affine, rotation, translation, scaling, and reflection. ```APIDOC ## Transformation Classes and Builder Functions ### Description This section documents the classes and functions for creating and manipulating geometric transformations. It covers affine transformations, rotations, translations, scaling, and reflections. ### Classes - **Transformation**: Base class for geometric transformations. - **TransformationCollection**: For composing multiple transformations. ### Builder Functions - **identity()**: Returns an identity transformation. - **affine_transform(...)**: Creates an arbitrary affine transformation. - **rotation(...)**: Creates a rotation transformation. - **translation(...)**: Creates a translation transformation. - **scaling(...)**: Creates a scaling transformation. - **reflection(...)**: Creates a reflection transformation. ### Methods - **apply(geometry)**: Applies the transformation to a geometric entity. - **inverse()**: Returns the inverse of the transformation. ### Usage Examples ```python from geometer import Point, rotation, translation pt = Point(1, 0, 0) # Rotate 90 degrees around Z-axis rot_z = rotation(angle=90, axis='z') rotated_pt = rot_z.apply(pt) # Translate by (0, 1, 0) tr = translation(vector=(0, 1, 0)) translated_pt = tr.apply(pt) # Combine transformations combined_tr = rot_z.compose(tr) final_pt = combined_tr.apply(pt) ``` ### See Also - [API Reference - point.md](/geometer/point.md) for applying transformations to points. - [Global Reference - types.md](/geometer/types.md) for transformation tensor types. ``` -------------------------------- ### Conic.from_points Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Constructs a conic passing through five points. ```APIDOC ## Conic.from_points ### Description Constructs a conic passing through five points. ### Method `classmethod` ### Parameters - **a** (Point) - Required - First point on the conic. - **b** (Point) - Required - Second point on the conic. - **c** (Point) - Required - Third point on the conic. - **d** (Point) - Required - Fourth point on the conic. - **e** (Point) - Required - Fifth point on the conic. (No three points should be collinear). ### Returns Conic through the five points. ### Example ```python from geometer import Point, Conic points = [Point(0, 0), Point(1, 0), Point(0, 1), Point(1, 1), Point(2, 2)] c = Conic.from_points(*points) ``` ``` -------------------------------- ### PointCollection Methods Source: https://github.com/jan-mue/geometer/blob/main/docs/source/modules.md Methods for the PointCollection class, including the `join()` operation. ```APIDOC ## PointCollection Methods ### Description Provides methods for PointCollection objects, including the `join()` operation. ### Methods - `join(other)`: Computes the join of the PointCollection with another geometric object. ``` -------------------------------- ### RegularPolygon Methods Source: https://github.com/jan-mue/geometer/blob/main/docs/source/modules.md Methods for the RegularPolygon class, including center, inradius, and radius. ```APIDOC ## RegularPolygon Methods ### Description Provides methods for RegularPolygon objects to access geometric properties. ### Methods - `center()`: Returns the center of the RegularPolygon. - `inradius()`: Returns the inradius of the RegularPolygon. - `radius()`: Returns the radius of the RegularPolygon. ``` -------------------------------- ### Import Transformation Builders Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/types.md Imports functions for creating common geometric transformations such as identity, rotation, translation, scaling, reflection, and affine transformations. ```python # Import transformation builders from geometer import ( identity, rotation, translation, scaling, reflection, affine_transform ) ``` -------------------------------- ### Plane.mirror Method Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/point.md Reflects a given point across the plane. This method is only applicable in 3D. ```python def mirror(self, pt: PointTensor) -> PointTensor ``` -------------------------------- ### Initialize Conic Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Initializes a Conic object, representing a two-dimensional conic section. Requires a matrix defining the conic. ```python Conic(matrix, is_dual=False, normalize_matrix=False, **kwargs) ``` -------------------------------- ### mirror(pt) Source: https://github.com/jan-mue/geometer/blob/main/docs/source/geometer.md Constructs the reflections of a point at the plane. This operation is restricted to 3D space. ```APIDOC ## mirror(pt) ### Description Construct the reflections of a point at the plane. Only works in 3D. ### Parameters #### Path Parameters - **pt** (PointTensor) - Required - The points to reflect. ### Response #### Success Response (200) - **result** (PointTensor) - The mirror points. ``` -------------------------------- ### Point.join Method Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/point.md Joins this point with other points or lines to form a line or plane. Can raise LinearDependenceError or NotCoplanar exceptions. ```APIDOC ## Point.join ### Description Joins this point with other points or lines to form a line or plane. ### Signature ```python def join(self, *others: Point | Line | PointCollection | LineCollection) -> Line | Plane | SubspaceTensor ``` ### Parameters #### Arguments - **`*others`** (Point | Line | PointCollection | LineCollection) - Required - Objects to join with this point. ### Returns A Line (if joining with 1 other point), Plane (if joining with 2 other points or a line), or SubspaceTensor. ### Raises - LinearDependenceError: If objects are linearly dependent or coincident. - NotCoplanar: For skew lines in 3D. ### Example ```python from geometer import Point, Line # Create two points and join them to form a line p = Point(0, 0) q = Point(1, 1) line = p.join(q) print(line) # Line in 2D space through p and q ``` ``` -------------------------------- ### Conic.from_crossratio Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Constructs a conic from a cross ratio and four points. ```APIDOC ## Conic.from_crossratio ### Description Constructs a conic from a cross ratio and four points. ### Method classmethod ### Parameters #### Path Parameters - **cr** (float) - Required - Cross ratio defining the conic. - **a** (Point) - Required - Four points on the conic. - **b** (Point) - Required - Four points on the conic. - **c** (Point) - Required - Four points on the conic. - **d** (Point) - Required - Four points on the conic. ### Response #### Success Response (Conic) - **Returns:** Conic with specified cross ratio. ### References J. Richter-Gebert: Perspectives on Projective Geometry, Section 10.2 ``` -------------------------------- ### Construct Conic from Foci Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Constructs a conic section given two focal points and a point on the boundary. Ensure Point objects are correctly defined. ```python from geometer import Point, Conic f1 = Point(-1, 0) f2 = Point(1, 0) bound = Point(2, 0) c = Conic.from_foci(f1, f2, bound) ``` -------------------------------- ### Construct Conic from Cross Ratio Source: https://github.com/jan-mue/geometer/blob/main/_autodocs/api-reference/curve.md Constructs a conic section using a cross ratio and four points. This method is based on projective geometry principles. ```python from geometer import Point, Conic # Example usage for from_crossratio would go here, but is not provided in the source. ```