Skip to content

Instantly share code, notes, and snippets.

View fospathi's full-sized avatar

Christian Stewart fospathi

View GitHub Profile
@fospathi
fospathi / lines_closest_approach.md
Created August 18, 2025 21:45
Closest points of approach of two lines

Closest points of approach of two lines

Let l1 and l2 be two lines such that their parametric vector equations are

l1 = a1 + t1*b1
l2 = a2 + t2*b2

where
@fospathi
fospathi / shear_with_plane.md
Last active August 16, 2025 11:17
Shear with a plane
@fospathi
fospathi / rotation_around_line.md
Last active August 16, 2025 11:24
Rotation around a line

Rotation around a line

Here, rotating around a line uses the concept of a change of basis. See Change of basis for further information.

Rotation around a line through the origin

The steps to perform a rotation around a line through the origin are

  1. Find any basis (x, y, z) such that the positive x-axis direction of the basis is codirectional with the direction of the line:
@fospathi
fospathi / reflection_in_plane.md
Last active August 16, 2025 11:26
Reflection in a plane

Reflection in a plane

Here, reflecting in a plane uses the concept of a change of basis. See Change of basis for further information.

Reflection in a plane through the origin

The steps to perform a reflection in a plane through the origin are

  1. Find any basis (x, y, z) such that the normal of the plane is codirectional with the positive x-axis direction of the basis:
@fospathi
fospathi / change_of_basis.md
Last active August 15, 2025 18:29
Change of basis transformation

Change of basis

Let C be a right-handed three-dimensional coordinate system.

Let R be a linear transformation that preserves an orthonormal basis, such as a rotation around or reflection through the origin.

Let R be applied to any point in C, say P, and let Q be the image of P:

R : P ↦ Q
@fospathi
fospathi / ndc_aspect_distortion.md
Last active March 14, 2023 15:21
Aspect distortion of relative vectors composed in NDC space

Aspect distortion of relative vectors composed in NDC space

The distortion affects relative vectors calculated in NDC (OpenGL Normalised Device Coordinates) space at the point at which they are mapped to a rectangular (i.e. non-square) screen.

Let the metric used to measure distance be the proportion of the height of the (NDC cube)/screen. Let's say we wish to calculate a position Q in NDC which is a desired distance from P on the screen.

@fospathi
fospathi / add_repo_gitlab.md
Last active April 23, 2020 20:27
How to create a new GitLab project from an existing local repository

Create a new GitLab project from an existing local repository

This SSH method assumes your SSH keys are already set up on Gitlab and your local system. The SSH method is preferable as it doesn't require a username and password like the HTTPS method.

In the commands below replace fospathi and nonexistent-project with your username and project name respectively. Execute these commands in the project's top-level directory which usually contains the project's .git directory and other language specific things like a go.mod file for Go modules.

Git push using SSH

Directly push the repo to GitLab to create the new project (some times this step takes multiple attempts before success):

@fospathi
fospathi / identical_errors_go.md
Last active May 5, 2024 16:15
Why are Go's identical errors not equal?

⚠️ This discussion applies to version 1.13 (released 2019) of the Go language.

Why are Go's identical errors not equal?

Or, more precisely, why are two separate but otherwise seemingly identical errors created by Go's errors.New function not equal according to the == operator?

Consider the output of the following small program (Go Playground link) which compares Go's error values for equality:

package main
@fospathi
fospathi / aimed_projectile_launch_angle.txt
Created July 31, 2018 10:24
Aimed projectile launch angle
An expression for the launch angle of a parabolic projectile which coincides with a target position vector (x, y) at some
point in its trajectory.
The parametric coordinates of a parabolic projectile launched from the origin are
x = uct
y = ust + at² / 2
where
@fospathi
fospathi / sin_unit_normal.txt
Last active September 27, 2020 16:30
Principal unit normal vector for a sin curve
An expression for the sin curve's principal unit normal vector.
The principal unit normal vector is different from a unit normal vector in that it always points from a point on the curve
towards the centre of the circle that most closely approximates the curvature of the curve at that point. Thus, the principal
unit normal vector is undefined at inflection points since the radius of the circle is infinite at these points.
Consider the parametric form of a sin curve. Let R be a general position vector on a sin curve and let
c = cos(t)
s = sin(t)