Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Braikenridge-Maclaurin Construction of a Conic #11205

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 29 additions & 27 deletions geometry/braik_mac_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# 5 Points define a conic section on a 2D normal
# orthogonal plane using this technique


@dataclass
class Point:
"""
Expand All @@ -30,6 +31,7 @@ def __post_init__(self) -> None:
if not isinstance(self.y, (int, float)):
raise TypeError("y must be an int or float numeric value")


@dataclass
class BraikMac:
"""
Expand All @@ -53,15 +55,15 @@ class BraikMac:
Point(x=2.0, y=3.0), Point(x=1.0, y=10.0), Point(x=6.0, y=7.0)])
"""

p_list : list[float] = field(default_factory=list)
p_list: list[float] = field(default_factory=list)

def __post_init__(self) -> None:
n = 0
for p in self.p_list:
if not isinstance(p, Point):
raise TypeError("Array must be point objects.")
n += 1
if n != 5 :
if n != 5:
raise TypeError("Array must be 5 point objects.")

@property
Expand All @@ -79,11 +81,11 @@ def generate(self) -> None:

x2_matrix = array(
[
[x1*y1, y1**2, x1, y1, 1],
[x2*y2, y2**2, x2, y2, 1],
[x3*y3, y3**2, x3, y3, 1],
[x4*y4, y4**2, x4, y4, 1],
[x5*y5, y5**2, x5, y5, 1],
[x1 * y1, y1**2, x1, y1, 1],
[x2 * y2, y2**2, x2, y2, 1],
[x3 * y3, y3**2, x3, y3, 1],
[x4 * y4, y4**2, x4, y4, 1],
[x5 * y5, y5**2, x5, y5, 1],
]
)

Expand All @@ -103,47 +105,47 @@ def generate(self) -> None:

y2_matrix = array(
[
[x1**2, x1*y1, x1, y1, 1],
[x2**2, x2*y2, x2, y2, 1],
[x3**2, x3*y3, x3, y3, 1],
[x4**2, x4*y4, x4, y4, 1],
[x5**2, x5*y5, x5, y5, 1],
[x1**2, x1 * y1, x1, y1, 1],
[x2**2, x2 * y2, x2, y2, 1],
[x3**2, x3 * y3, x3, y3, 1],
[x4**2, x4 * y4, x4, y4, 1],
[x5**2, x5 * y5, x5, y5, 1],
]
)

c = linalg.det(y2_matrix)

x_matrix = array(
[
[x1**2, x1*y1, y1**2, y1, 1],
[x2**2, x2*y2, y2**2, y2, 1],
[x3**2, x3*y3, y3**2, y3, 1],
[x4**2, x4*y4, y4**2, y4, 1],
[x5**2, x5*y5, y5**2, y5, 1],
[x1**2, x1 * y1, y1**2, y1, 1],
[x2**2, x2 * y2, y2**2, y2, 1],
[x3**2, x3 * y3, y3**2, y3, 1],
[x4**2, x4 * y4, y4**2, y4, 1],
[x5**2, x5 * y5, y5**2, y5, 1],
]
)

d = -linalg.det(x_matrix)

y_matrix = array(
[
[x1**2, x1*y1, y1**2, x1, 1],
[x2**2, x2*y2, y2**2, x2, 1],
[x3**2, x3*y3, y3**2, x3, 1],
[x4**2, x4*y4, y4**2, x4, 1],
[x5**2, x5*y5, y5**2, x5, 1],
[x1**2, x1 * y1, y1**2, x1, 1],
[x2**2, x2 * y2, y2**2, x2, 1],
[x3**2, x3 * y3, y3**2, x3, 1],
[x4**2, x4 * y4, y4**2, x4, 1],
[x5**2, x5 * y5, y5**2, x5, 1],
]
)

e = linalg.det(y_matrix)

const_matrix = array(
[
[x1**2, x1*y1, y1**2, x1, y1],
[x2**2, x2*y2, y2**2, x2, y2],
[x3**2, x3*y3, y3**2, x3, y3],
[x4**2, x4*y4, y4**2, x4, y4],
[x5**2, x5*y5, y5**2, x5, y5],
[x1**2, x1 * y1, y1**2, x1, y1],
[x2**2, x2 * y2, y2**2, x2, y2],
[x3**2, x3 * y3, y3**2, x3, y3],
[x4**2, x4 * y4, y4**2, x4, y4],
[x5**2, x5 * y5, y5**2, x5, y5],
]
)

Expand Down