Skip to content
/ model Public

generate classical geometric constructions with the precision of symbolic algebra

License

Notifications You must be signed in to change notification settings

geometor/model

Repository files navigation

geometor.model` is the foundational library for the GEOMETOR initiative.

Additional information about geometor.model can be seen at the `Project's Website`_

mission

The mission of this module is to establish a rigorous system for defining classical geometric constructions of points, lines and circles. But in our case, we are not using straight edge and compass. We are creating the geometric elements as expressions in symbolic algebra thanks to the power of the Sympy library.

overview

At the core of the module is the Model class which establishes the field and methods of operation for creating the geometric constructions while maintaining integrity.

The field might be easy to consider as a Cartesian grid. But in reality, it is an ordered set of information and operations. Points are the information. Lines and circles are the operations.

In our system, all geometric elements of the Model are defined as Sympy Geometry objects. This means a Point can be defined as a pair of any algebraic Sympy Expressions that can be evaluated into a floating point value.

Line and Circle are each defined by two points. So each construction must begin with at least two given points at the start. As lines and circles are added, intersection points are discovered with previous lines and circles and added to the model, so they may be used with new lines and circles.

There are three main operations of the Model:

  • set_point
  • construct_line
  • construct_circle

The major responsibilities of the Model:

  • deduplicate

    when elements are added to the model, we check to see if they already exist. This is particularly important for intersection points that often coincide with exisitng points.

  • clean values

  • discover intersections

  • save to and load from json

  • maintain a set of related info for each element:

    • ancestral relationships
    • establish labels for elements
    • classes for styles

All of the plotting functionality has moved to GEOMETOR render. However, there are several report functions in the this module:

  • report_summary
  • report_group_by_type
  • report_sequence

screenshot.png

installation

You can install geometor.model using pip:

pip install geometor-model

or clone this repo and install it directly.

git clone https://github.com/geometor/model
cd model
pip install -e .

usage

In this simple example, we create the classic vesica pisces

from geometor.model import *

model = Model("vesica")
A = model.set_point(0, 0, classes=["given"])
B = model.set_point(1, 0, classes=["given"])

model.construct_line(A, B)

model.construct_circle(A, B)
model.construct_circle(B, A)

E = model.get_element_by_label("E")
F = model.get_element_by_label("F")

model.set_polygon([A, B, E])
model.set_polygon([A, B, F])

model.construct_line(E, F)

report_summary(model)
report_group_by_type(model)
report_sequence(model)

model.save("vesica.json")

dependencies

model depends on the following Python packages:

  • sympy
  • rich
  • textual
  • jinja2
  • numpy (this may now not be required)

contributing

Contributions are welcome!

Please see our Issues for specific opportunities.

Share thoughts in the Discussions forum

license

model is licensed under the MIT License. See the LICENSE file for more details.

About

generate classical geometric constructions with the precision of symbolic algebra

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published