Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit 5557e8c

Browse files
committed
Add draft documentation and updated API docs
1 parent 57f9078 commit 5557e8c

File tree

6 files changed

+178
-13
lines changed

6 files changed

+178
-13
lines changed

docs/js/extra.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
(function () {
22
'use strict';
33

4+
var macros = {
5+
'\\ee': '\\mathbf{e}',
6+
};
7+
48
var katexMath = (function () {
59
var maths = document.querySelectorAll('.arithmatex'),
610
tex;
711

812
for (var i = 0; i < maths.length; i++) {
913
tex = maths[i].textContent || maths[i].innerText;
1014
if (tex.startsWith('\\(') && tex.endsWith('\\)')) {
11-
katex.render(tex.slice(2, -2), maths[i], { 'displayMode': false });
15+
katex.render(tex.slice(2, -2), maths[i], { 'displayMode': false, macros });
1216
} else if (tex.startsWith('\\[') && tex.endsWith('\\]')) {
13-
katex.render(tex.slice(2, -2), maths[i], { 'displayMode': true });
17+
katex.render(tex.slice(2, -2), maths[i], { 'displayMode': true, macros });
1418
}
1519
}
1620
});

docs/js/tutorial.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const vs_src = `
2+
attribute vec4 a_pos;
3+
uniform mat4 u_mvp;
4+
uniform mat4 u_proj;
5+
6+
void main() {
7+
gl_Position = u_proj * u_mvp * a_pos;
8+
}
9+
`;
10+
11+
const fs_src = `
12+
void main() {
13+
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
14+
}
15+
`
16+
17+
function init_canvas(cv) {
18+
const gl = cv.getContext('webgl');
19+
20+
gl.clearColor(0, 0, 0, 1.0);
21+
gl.clear(gl.COLOR_BUFFER_BIT);
22+
}
23+
24+
function load_default(gl) {
25+
const prog = link_program(gl, vs_src, fs_src);
26+
if (!prog) {
27+
return null;
28+
}
29+
30+
return {
31+
prog,
32+
a_pos: gl.getAttribLocation(prog, 'a_pos'),
33+
u_mvp: gl.getAttribLocation(prog, 'u_mvp'),
34+
u_proj: gl.getAttribLocation(prog, 'u_proj'),
35+
}
36+
}
37+
38+
function load_shader(gl, type, source) {
39+
const shader = gl.createShader(type);
40+
gl.shaderSource(shader, source);
41+
gl.compileShader(shader);
42+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
43+
console.error(gl.getShaderInfoLog(shader));
44+
gl.deleteShader(shader);
45+
return null;
46+
}
47+
return shader;
48+
}
49+
50+
function link_program(gl, vs, fs) {
51+
const vert = load_shader(gl, gl.VERTEX_SHADER, vs);
52+
const frag = load_shader(gl, gl.VERTEX_SHADER, fs);
53+
54+
const prog = gl.createProgram();
55+
gl.attachShader(prog, vert);
56+
gl.attachShader(prog, frag);
57+
gl.linkProgram(prog);
58+
59+
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
60+
console.error(gl.getProgramInfoLog(prog));
61+
gl.deleteShader(vert);
62+
gl.deleteShader(frag);
63+
return null;
64+
}
65+
66+
return prog;
67+
}

docs/tutorial.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/tutorial/exterior_algebra.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
!!! danger
2+
3+
You are currently reading a DRAFT that is available publicly to facilitate collaboration
4+
5+
In the [introduction](../intro), we considered a set of three basis vectors $\ee_1$,
6+
$\ee_2$, and $\ee_3$. In addition, we pontificated a bit on why restricting ourselves to
7+
vectors can cause issues, and argued for the need for a richer structure to match the
8+
richness of the geometry. But how should we go about doing this?
9+
10+
In 3-dimensions, it seems a bit unfair that only "arrows"
11+
can be represented. After all, our world is filled with objects that have area and
12+
volume too. Suppose we wanted to represent a unit area in the x-y plane. Let's give it
13+
a name, say $\ee_{12}$. It seems reasonable that the areas $\ee_{13}$ and $\ee_{23}$.
14+
But wait! Our choice of of index order seems a bit arbitrary. What about $\ee_{21}$,
15+
$\ee_{31}$ and $\ee_{32}$. If we follow our nose a bit, it seems reasonable that the
16+
area represented by $\ee_{12}$ should equal $-\ee_{21}$. After all, they possess opposite
17+
orientations from one another. What about elements with two repeated indices? Like $\ee_{11}$
18+
or $\ee_{33}$? Well, such elements can't reasonably span any area, so let's get back to
19+
how we should handle those in a moment. Like the unit vectors, it seems sensible to allow
20+
us to scale these area-elements with a weight (like $3\ee_{12}$) and add them together
21+
to create areas of arbitrary weight and orientation. So, for example, let's try to add
22+
$\ee_{12} + 2\ee_{23}$. What should its orientation be?
23+
24+
TODO!
25+
26+
For volumes, we have one choice that spans a non-zero volume which is $\ee_{123}$. We
27+
could have also chosen a different basis ordering, which again we'll get back to later.
28+
Let's call our single-index elements _vectors_ as before, the two-index elements _bivectors_,
29+
and the three-index elements _trivectors_.
30+
31+
TODO!

docs/tutorial/intro.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
!!! danger
2+
3+
You are currently reading a DRAFT that is available publicly to facilitate collaboration
4+
5+
<script src="../../js/tutorial.js"></script>
6+
7+
This guide is meant to be a gentle intro to Projective Geometric Algebra,
8+
also referred to as $\mathbf{P}(\mathbb{R}^*_{3, 0, 1})$. It assumes no
9+
knowledge of quaternions and dual-quaternions, but if you have some familiarity
10+
of either, you may find yourself armed with a new appreciation for them. Also not assumed
11+
is any knowledge of abstract algebra, or any specific algebra closely related to Geometric
12+
Algebra (e.g. exterior algebra, Clifford Algebra, etc.).
13+
14+
The emphasis first is on just getting familiarity with the notation and the various
15+
operations and what they do. The [references](../../references) page on the left contains
16+
some excellent references if you prefer a bottom up approach. Here though, the goal will
17+
be to build your intuition primarily through examples, and then introduce the formalism
18+
afterwards.
19+
20+
!!! tip
21+
22+
Grab a pen and paper! You are expected to work out a number of expressions by hand
23+
and _see_ for yourself that the formulae behave as advertised. Further, drawing pictures
24+
is _very_ important to maintain the linkage between the algebra and the geometry.
25+
26+
We're going to go straight to 3D, so hang on tight. Let's start with three perfectly
27+
ordinary basis vectors, $\ee_1$, $\ee_2$ and $\ee_3$. Now, normally when we think about
28+
vectors, we imagine that they have some length and direction. In this case, let's have
29+
$\ee_1$ point in the x-direction, $\ee_2$ point in the y-direction, $\ee_3$ point in the
30+
z-direction, and give all of them unit length. Each one of these basis vectors can be
31+
scaled by a weight, and we can take linear combinations of them to create any vector
32+
in our 3D space. So far, everything behaves just like your good ol' 3D vector space.
33+
34+
Now, let's pause and consider for a moment what our vector space might be lacking. With
35+
vectors alone, we can certainly come up with ways to represent all sorts of things.
36+
Sometimes, vectors are arrows from the origin. Other times, we use vectors to mean the
37+
point terminated at by that arrow. Still other times, a vector is used to represent a
38+
plane through the origin by encoding the normal to the plane. In a way, vectors are
39+
somewhat encumbered due to the need to represent _all_ the various entities in geometry
40+
one way or another. But even if we try, we'll find that there are still aspects of geometry
41+
that we can't reasonably or easily represent with vectors. For example, what if the
42+
plane didn't go through the origin? I suppose we could use two vectors, one for the normal,
43+
and one to describe a point in the plane. What about a rotation? Maybe we use a vector
44+
for the axis, and a number for the rotation. Translations? Maybe the vector points in the
45+
direction of the translation and the length encodes the displacement. Do you see
46+
an issue with the way things are going with this thought exercise? All of these
47+
interpretations of what a "vector" is are not mutually compatible with one another! We
48+
certainly can't add a vector intended to be used as a rotation axis and a vector intended
49+
to be used as a plane normal and expect to have a consistent interpretation of the result.
50+
All of them need to be treated distinctly and live "in their own space" as it were, with
51+
very delicate code to keep the invisible boundaries between them uncrossed.
52+
53+
Needless to say, mathematically, the situation described above leaves much to be desired.
54+
What we'd like is an algebra (aka the Geometric Algebra) that could describe all the entities
55+
we need (points, lines, planes, rotations, translations, to name a few) in a _unifying_
56+
framework glued by an operation which has a sensible meaning when its operands are any
57+
of the listed entities (aka the geometric product). To make this a reality though, we're
58+
going to need to move past our vector space and limited set of operations to an algebra
59+
that is much richer. This algebra (the Geometric Algebra) will have more operations than
60+
you're used to, and more "things" than you're used to, but that's to be expected. After all,
61+
geometry is far richer than just arrows emanating from the origin. Embracing the additional
62+
structure is in some sense, akin to embracing the reality that is geometry itself, and
63+
acknowledge that the algebra is going to need to play some catch up to describe the
64+
geometry more aptly. So, then, aside from vectors, what else do we need? In the next
65+
section, we'll describe the exterior algebra as a stepping stone to geometric algebra,
66+
so see you there!

mkdocs.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ theme:
1010
tabs: false
1111
logo:
1212
icon: 'flip'
13-
site_url: https://jeremyong.com/klein
14-
repo_url: https://github.com/jeremyong/klein
15-
repo_name: 'jeremyong/klein'
13+
site_url: https://jeremyong.com/Klein/
14+
repo_url: https://github.com/jeremyong/Klein/
15+
edit_uri: ''
16+
repo_name: 'jeremyong/Klein'
1617
site_description: Klein - Realtime Projective Geometric Algebra
1718
site_author: Jeremy Ong
1819
copyright: 'Klein Copyright &copy; 2020 Jeremy Ong'
@@ -36,19 +37,20 @@ nav:
3637
- 'Direction': 'api/kln::direction.md'
3738
- 'Mat4x4': 'api/kln::mat4x4.md'
3839
- 'Origin': 'api/kln::origin.md'
39-
- 'Tutorial': 'tutorial.md'
40+
- 'Tutorial':
41+
- 'Introduction': 'tutorial/intro.md'
42+
- 'Exterior Algebra': 'tutorial/exterior_algebra.md'
4043
- 'Klein Shell': 'shell.md'
4144
# - 'Benchmarks': 'benchmarks.md'
4245
- 'Roadmap': 'roadmap.md'
4346
- 'References': 'references.md'
4447

45-
edit_uri: ''
46-
4748
extra_css:
4849
- 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css'
4950

5051
extra_javascript:
5152
- 'js/extra.js'
53+
- 'https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js'
5254
- 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js'
5355

5456
markdown_extensions:

0 commit comments

Comments
 (0)