Skip to content

Add utility geometry construction methods#71

Draft
tomcur wants to merge 1 commit intomainfrom
vocabulary
Draft

Add utility geometry construction methods#71
tomcur wants to merge 1 commit intomainfrom
vocabulary

Conversation

@tomcur
Copy link
Copy Markdown
Contributor

@tomcur tomcur commented Aug 13, 2025

See the last commit: 8e127d6.

This starts thinking about utility construction methods, to expressively build geometry on top of other geometry. This is directly motivated to allow potentially dropping the current references system (where, e.g., a circle is constructed from a reference to a point and a reference to a length, and constraints can simultaneously be placed on the referenced point and the circle built on top of it).

These methods introduce a way of constructing the same kind of geometry through the normal constraint system. This can be more expressive, as it allows creating geometry that cannot be represented directly with references (e.g., something like elements::Rectangle::point_at_top_right, where the rectangle is not represented by a point in that location). There is some cost, as references are "free": they represent the same variables, and thus their relationships are trivially true. On the other hand, references make degree-of-freedom analysis harder, thereby complicating system analysis and decomposition.

For example, instead of the following.

let mut s = System::new();

let center = elements::Point::create(&mut s, 0., 0.);
let p1 = elements::Point::create(&mut s, 5., 0.);
let p2 = elements::Point::create(&mut s, 10., 1.);
let circle = elements::Circle::create(&mut s, center, 2.);

constraints::PointCircleIncidence::create(&mut s, p1, circle);
constraints::PointCircleIncidence::create(&mut s, p2, circle);
constraints::PointPointPointAngle::create(&mut s, p1, center, p2, 20_f64.to_radians());
constraints::PointPointDistance::create(&mut s, p1, p2, 15.);

You'd write the following.

let mut s = System::new();

let circle = elements::Circle::create(&mut s, (0., 0.), 2.);
let center = circle.create_point_at_center(&mut s);
let p1 = circle.create_incident_point(&mut s);
let p2 = circle.create_incident_point(&mut s);

constraints::PointPointPointAngle::create(&mut s, p1, center, p2, 20_f64.to_radians());
constraints::PointPointDistance::create(&mut s, p1, p2, 15.);

We could also have methods like elements::Line::create_through_points(&mut s, p1, p2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant