2DPGA: Project and rejectΒΆ
This example shows how to perform projection and rejection, using 2DPGA.
Based on https://enkimute.github.io/ganja.js/examples/coffeeshop.html#pga2d_project_and_reject.
First we create 2DPGA, and add its basis blades to the local namespace.
[1]:
from kingdon import Algebra
alg = Algebra(2, 0, 1)
locals().update(alg.blades)
Next, make formulas to construct points and lines from coefficients, and to project and reject any elements of geometry.
[2]:
# Construct points and lines from coefficients
point = lambda x, y: (e0 + x*e1 + y*e2).dual()
line = lambda a, b, c: a*e1 + b*e2 + c*e0
# The formulas for projection and rejection are the same for all elements of geometry in PGA
project = lambda a, b: (a | b) / b
reject = lambda a, b: (a | b)
Construct the points \(A\), \(B\), and \(C\), and make the line \(AC\) by joining \(A\) and \(C\).
[3]:
A = point(1, 1)
B = point(-1, 1)
C = point(-1, -1)
AC = A & C
[4]:
alg.graph(
0xD0FFE1, [A,B,C],
0x882288, project(B, AC), "project B onto AC",
0x882288, project(AC, B), "project AC onto B",
0x008844, reject(AC, B), "reject AC from B",
0x00AA88, AC, "AC",
0x224488, A, "A", B, "B", C, "C",
lineWidth=3, grid=1, labels=1
)
[4]:
[ ]: