# Is there something like: Raytracing in one Weekend in PGA?

I was looking to familiarize myself with PGA by implementing a simple renderer preferable a raytracer with PGA. Is there any material in that direction? Thank you.

Hi, @Rimaan !

I’m not aware of much guided material like that. I recently did a workshop with a few such guided exercises - not for raytracing but for inverse kinematics. Here are the links :

https://enki.ws/ganja.js/examples/coffeeshop.html#spider1

https://enki.ws/ganja.js/examples/coffeeshop.html#spider2

https://enki.ws/ganja.js/examples/coffeeshop.html#spider3

https://enki.ws/ganja.js/examples/coffeeshop.html#spider4

https://enki.ws/ganja.js/examples/coffeeshop.html#spider5

https://enki.ws/ganja.js/examples/coffeeshop.html#spider6

Solutions are linked in each of the exercises, and being in the coffeeshop you can just hit save to fork/store your own copy.

Cheers,

Steven

1 Like

Thank you very much. Do you know of any material on how to calculate the intersection of a line with a triangle in PGA?

Sorry for chiming in: I assume that you work in three dimensional PGA. A triangle is given by three points P_1, P_2, P_3. You can calculate the plane of the triangle via {\bf p} = P_1 \vee P_2 \vee P_3. The intersection point X of a line \ell with the plane {\bf p} is then given by X = \ell \wedge {\bf p}. Now you still have to check, whether X lies within the triangle P_1, P_2, P_3. I think, you have to construct planes perpendicular to {\bf p} and such that the lines P_1 \vee P_2, P_2 \vee P_3, P_3 \vee P_1 lie within these planes. Then you have to check whether X lies at the correct side of those planes. But I have to consult the cheat sheet of Charles and Steven to find the correct formula. Hope, this helps as a first step. 1 Like

Thank you for the answer, I’m trying something slightly different now. No, the plane of a triangle is a bivector area:

\frac{(P_2-P_1) \wedge (P_3-P_1)}{(3-1)!}

Actually, it is a whole equivalence class of such expressions.

This is because you need to convert the 3 points into a vector frame basis by subtracting a base point, resulting in 2 vectors whose determinant product is the plane area on which the triangle is located.

Check if a point is inside a simplex is obtained from partial application of Cramer’s rule for solving linear systems and then checking the orientations are same when taking the products.

P_0 \in P_{1...n} \iff \forall i : P_{1...n} = P_{1...(i-1)} \wedge P_0 \wedge P_{(i+1)...n}

My Grassmann.jl of course makes this all rather simple to do:

julia> using Grassmann

julia> P1 = Chain(1,0,0)
1v₁ + 0v₂ + 0v₃

julia> P2 = Chain(1,1,0)
1v₁ + 1v₂ + 0v₃

julia> P3 = Chain(1,0,1)
1v₁ + 0v₂ + 1v₃

julia> tri = Chain(P1,P2,P3)
(1v₁ + 0v₂ + 0v₃)v₁ + (1v₁ + 1v₂ + 0v₃)v₂ + (1v₁ + 0v₂ + 1v₃)v₃

julia> (P2-P1)∧(P3-P1)/factorial(3-1)
0.0v₁₂ + 0.0v₁₃ + 0.5v₂₃

julia> ∧(Grassmann.vectors(tri))/factorial(3-1)
0.5v₂₃

julia> P0 = Chain(1.,0.5,0.5)
1.0v₁ + 0.5v₂ + 0.5v₃

julia> P0 in tri
true


In PGA a plane is a vector, a line is a bivector and a point is a trivector.

That is incorrect. In projective geometry, a point is a vector with an origin. That trivector should not be referred to as a point, as the term “point” in projective geometry has been well defined for over a century, and it’s not defined as a trivector.

This is another example of non-mathematicians using inconsistent mathematical terminology.

PGA acronym stands for projective geometric algebra, which implies projective geometry applied to geometric algebra. The history of projective geometry is well known for over a century, and a point in projective geometry has always been a homogeneous vector.

Please find appropriate words for these things and stop using inappropriate and inconsistent terminology.

I use the code generated by this website for CL(3,0,1) and there a plane is indeed represented as a vector and so on. Whether this will proof useful the future will show.

I think you are very confused (as well as the people who make this website).

What you are probably referring to is called a “hyperplane” instead of a point.

Hyperplanes and vectors are complement of each other, but not to be confused with one another.

The concept of a hyperplane is useful, but confusing the terminology like this website does is overall bad for the consistency of mathematical terminology.

No what I refer to is the meet of three planes which is a point and represented as a trivector in this framework.

Politicians also think they can flip the meaning of everything, they think people serve politicians, instead of politicians serving people.

What you’re using is backwards terminology, just like politicians like to twist things to their point of view.