Math: General

Updated: July 2024

Introduction

Robotics is a field that requires math. Like a lot of it. It's one step below scientific simulations and computer graphics. It relies on a wide range of topics, but usually has a viable solution using only fundamentals. Lets go over many of the topics that come up in robotics, embedded systems, and primitive AI. Keep an eye out for bolded lines, they are questions you should be able to answer at that point.

The rest of this article assumes the reader has a basic understanding of algebra, and how to solve equations. If you are a freshmen, don't panic! Everything covered should be within your grasp after your first year or two of high school.

Geometry

Geometry is so critical to everything we do. Spatial reasoning, mechanical engineering, rushing through the grocery store as quick as possible, or maybe you recently found out just how many things can fit into the square hole.

It is especially important to robotics and CAD software. Computer-Aided Design software is not explicitly a tool for laying out geometry with automated equations and analysis for engineers, but that is what the term has become. If you haven't taken a class on CAD from any mentors, give it a shot. It will expand your knowledge of robot design quite a bit!

Trigonometry

This is the study on the relationship between triangles and circles. While at a surface level the two couldn't be less similar, they are in fact tightly related by the way of right triangles and the unit circle. Pay close attention to the relationship between degrees and radians, 1π = 180°.

Lets get the unit circle out of the way first, it's a very special and powerful shape. The unit circle has a radius of 1, and its points can be represented in either cartesian coordinates (ie, {x, y}) or polar coordinates (ie, {θ, r}). Note that in polar coordinates since the radius is always 1 it can be left off if stated.

Loading...

What's great about this shape is that each point on the circle represents a pair of calculations: {x, y} = {cos(θ), sin(θ)}. Each can be derived from the other. This relationship comes up constantly in the real world, engineering, and physics, whether it's intended or not.

Now lets look at the right triangle. That previous relationship only holds true in a right triangle: a triangle with a 90 degree angle. This is because of the identity property of 1. When you form the pythagorean equation with a unit circle, you see that c=1 and 1=a2+b2. It may not seem like much, but this simple equation opens up a lot of doors.

Given value of a point on the unit circle, could you calculate the y value if you know the x value is sin(π/6)?
( sin() is deliberate, keep your answer in terms of cos() or sin() )


Arc Length

Lets build off the idea of curved distances, and for simplicities sake we'll use a circle still. This is something called anArc Length. You can estimate the distance of an arc length by drawing a chordbetween two points on a circle, and calculating the length of that line. Since you've just graduate from Trigonometry School, you can calculate those two points along any circle. As a hint to make this simpler, you can actually tackle this problem by starting off with only 1 point because any arclength of radius θ has the same result at any spot on a circle, and the start of a circle is always at {r, 0} which is both a polar coordinate {r, θ} and a cartesian coordiate {x, y}. Once you have your second coordinate in cartesian values, observe that the chord is shorter than the arclength over those 2 points.

This is an estimate, and as you add more points and make smaller and smaller line segments, you get a total distance that grows and converges on the real value: θradians * r.

Knowing this, what would be the arc length of a circle over 138 degrees if that circle had a radius 3.5 times the radius of a unit circle?

Congratulations! You've just stumbled upon the origin of Euler's Method (pronounced oiler), and one of the basic principles of calculus!

Still not convinced? Lets think about the circumference of a circle, which is πd or 2πr. If you have a 90° angle, that's 1/4 of the circumference and our arc length equation says we should get 1/2πr. So if we start with c=2/1*πr=4/2*πr, and you divide both sides by 4, you get 1/4*c=1/2πr, which definitely matches!

Vectors

A vector is an organized set of values. Each position represents a specific dimension, or aspect of the data. For instance, when calculating the slope of a line on a graph, you may take the rise and divide it by the run. This is calculated from y2-y1 and x2-x1, right? This also just so happens to describe a vector, seen here { Δx, Δy }.

This extends into as many dimensions as you like. Including by 1 dimensional vectors (also called scalars), 3 and 4 element vectors like what are used in robotics and video games, or even 300 element vectors like in machine learning. All of the techniques we will talk about work across any sized vector. A vector is just an organized set of multiple numbers, that's it!

What's also nifty is that, while people typically use the x - y - z pattern, any order is valid so long as it's consistent. For the sake of this library, we will stick with the x - y - z pattern.


Vector Addition

So we can describe a vector, so what? A lot, actually. Vectors are fundamental to a wide range of domains, and the most fundamental of all is vector addition. This is frequently called "tip to tail" as memorable visualization of the steps. You see when you place vectors tip to tail, and add the Δx components together and then the Δy components together, you get a new vector of x and y values. Take this image as an example.

Projection Type Image

This is an example of what happens when you add two velocity vectors together:aim+moving=actual. If you were to slide the moving vector to the right, so that the tail of it touched the tip of the aim vector, you would see the tip of moving touch the tip of actual. So lets look at the numbers then: aim is {2, 0}, moving is {-1, -1}, actual is {1, -1}.

What is the vector equation to produce the vector moving? ( Give both numerical vector form, and individual equations for each element )


Unit Vector

There's a specialized type of vector called a unit vector, it's any vector with a magnitude /length of 1. There's a big reason it's called a unit vector, and it definitely ties back to the unit circle from before!

For a moment, take another glance at both the moving and actual vectors above. They have different x values, but still have the same length: √(2). This is because vectors of any number of dimensions all obey pythagoras theorem: a2+b2=c2, or hypotenuse = √(a2+b2). For vectors of 1 dimension, the magnitude is itself. For vectors of 3 dimensions, the magnitude is √(a2+b2+c2), and so on.

Any vector can be normalized to a unit vector by dividing it by its length, and the results are incredibly useful as you can see in other articles within the library. The terms become trigonometric values, and can be applied in a wide range of scenarios as a set of scalars, or in element wise operations.