2D Points and Vectors
2D Vector
Vector Between Two 2D Points
Norm of a 2D Vector
Euclidean Distance Between Two 2D Points
For two points
2D Manhattan Distance
2D Dot Product
For two vectors
Distance from a Point to a Line
For a point
3D Points and Vectors
3D Vector
Vector Between Two 3D Points
Norm 3D
Distance Between Two 3D Points
For two points
3D Dot Product
For two vectors
3D Cross Product
For two vectors
The cross product generates a vector perpendicular to the two given vectors, useful for normal calculations on surfaces.
Normalization
Normalization of a Vector
A normalized vector has a magnitude of 1 and is calculated by dividing each component by the magnitude of the vector:
Important for working with directions in graphics.
Angle Between Two Vectors
For two vectors
2D Polygons
Perimeter of a Polygon
where
Or by its coordinates
Area of a Polygon
For a polygon with vertices
where
Convexity of a Polygon
A polygon is convex if all internal angles are less than
Point Inside a Polygon
Given a polygon
- If the number of crossings is odd,
is inside the polygon - If even, it is outside.
2D Transformations
Translation
For a point
Rotation
To rotate a point
Scaling
To scale a point