golden sections

Divine identifies points that divide segments into the golden ratio (\(\phi\)).

Find and analyze exact symbolic golden sections in GEOMETOR models.

This module provides fast numerical pre-filtering paired with 100% exact Rational Trigonometry symbolic verification (geometor.model.quadrance() and geometor.model.zero_test()) to detect golden sections and chains across lines and collinear point configurations in geometor.model.Model.

class geometor.divine.golden.GoldenFieldTracker(*, include_guides: bool = False, tag_model: bool = True)

Bases: object

Incrementally track golden sections created as points and lines enter a Model.

attach(model: Model) → GoldenFieldTracker

Register this tracker as model’s analysis hook.

on_point_added(model: Model, pt: Point2D) → None

Index any new lines and check all new golden sections created by pt.

sync(model: Model) → None

Index any lines added after the last point event.

class geometor.divine.golden.PointImpact(section: Section, role: str, line: Line)

Bases: object

A golden section brought into the field when a point is added.

section: Section
role: str
line: Line
geometor.divine.golden.analyze_harmonics(line: Line) → list[tuple[Point, ...]]

Analyze a line for harmonic ranges.

Parameters:

line – The line to analyze.

Returns:

A list of harmonic ranges (tuples of 4 points).

Return type:

list

geometor.divine.golden.analyze_harmonics_by_segment(sections_by_line: dict) → dict

Group harmonic ranges by segment.

Parameters:

sections_by_line – Dictionary of sections by line.

Returns:

Nested dictionary mapping lines to segments to harmonic ranges.

Return type:

dict

geometor.divine.golden.check_range(r: tuple[Point, ...]) → Expr

Check if a range of 4 points forms a harmonic range.

Parameters:

r – A tuple of 4 points.

Returns:

The cross ratio value (0 if harmonic).

Return type:

sp.Expr

geometor.divine.golden.find_chains_in_model(model: Model, *, include_collinear: bool = True, include_guides: bool = False) → tuple[list[Section], list[Chain]]

Scan model for all exact golden sections and connected golden chains.

geometor.divine.golden.find_chains_in_sections(sections: list[Section]) → dict[Section, dict]

Identify maximal chains of connected golden sections.

Two ordered sections (A, B, C) and (B, C, D) connect when the trailing segment (B, C) of the first equals the leading segment (B, C) of the second.

Parameters:

sections – A list of Section objects to analyze.

Returns:

Tree structure mapping root Section nodes to nested dictionaries of connected successor Section nodes.

Return type:

dict

geometor.divine.golden.find_golden_sections_in_model(model: Model, *, include_collinear: bool = True, include_guides: bool = False, use_pool: bool = False) → tuple[list[Section], dict[Line, list[Section]]]

Analyze all lines and collinear point triples in model for golden sections.

Parameters:
  • model – The exact symbolic Model to analyze.

  • include_collinear – When True (default), also sweep maximal collinear point triples on segments or circle-only configurations without requiring an infinite sympy.geometry.Line in model.lines.

  • include_guides – Whether to include guide points and guide lines.

  • use_pool – Whether to use multiprocessing.Pool per line.

Returns:

(sections, sections_by_line) containing deduplicated exact golden Section instances and a mapping from carrier lines to their golden sections.

Return type:

tuple

geometor.divine.golden.find_golden_sections_in_points(pts: Sequence[Point2D], *, use_pool: bool = False) → list[Section]

Find all exact golden sections among 3-point combinations of collinear points.

Parameters:
  • pts – Collinear SymPy points to analyze.

  • use_pool – If True, evaluate candidates across a process pool; defaults to fast in-process screening + exact algebraic proof.

Returns:

Exact golden sections ordered along the line.

Return type:

list[Section]

geometor.divine.golden.group_sections_by_points(sections: list[Section]) → dict[Point, list[Section]]

Group sections by the points they contain.

Parameters:

sections – List of sections to group.

Returns:

Mapping of point to list of sections.

Return type:

dict

geometor.divine.golden.group_sections_by_segments(sections: list[Section]) → dict[Segment, list[Section]]

Group sections by the segments they contain.

Parameters:

sections – List of sections to group.

Returns:

Mapping of segment to list of sections.

Return type:

dict

geometor.divine.golden.group_sections_by_size(sections: list[Section]) → dict[Expr, list[Section]]

Group sections by their minimum length.

Parameters:

sections – List of sections to group.

Returns:

Mapping of length expression to list of sections.

Return type:

dict

geometor.divine.golden.is_section_golden(section_points: Sequence[Point2D]) → bool

Check whether three ordered collinear points form an exact golden section.

First screens segment quadrances numerically, then proves exact equality Q_long - (phi + 1) * Q_short == 0 symbolically via quadrance() and zero_test().

Parameters:

section_points – Sequence of three ordered collinear points (P, Q, R).

Returns:

True if max(|PQ|, |QR|) / min(|PQ|, |QR|) == phi exactly.

Return type:

bool

geometor.divine.golden.points_on_line(model: Model, line: spg.LinearEntity2D, *, include_guides: bool = False, point_floats: dict[spg.Point2D, tuple[float, float]] | None = None) → list[spg.Point2D]

Return all model points incident with line verified symbolically.

Uses floating-point line residual screening followed by exact zero_test() verification on the implicit line equation a*x + b*y + c = 0.

geometor.divine.golden.unpack_chains(tree: dict[Section, dict]) → list[Chain]

Unpack a chain tree into a list of individual Chain objects.

Parameters:

tree – Tree structure returned by find_chains_in_sections().

Returns:

Connected golden-section chains.

Return type:

list[Chain]