Here Simon explains how to calculate the magnitude of a 3D vector. This is something he partially figured out on his own and partially learned from Daniel Shiffman’s tutorial on Trigonometry and Polar Coordinates.

Skip to content
# Tag: trigonometry

# Magnitude of a 3D vector

# Teaching SOHCAHTOA to Grandmom in Russian

# Translating examples from The Nature of Code into Lua (Codea)

# Polar Roses in JavaScript

# Math > Back to Brilliant.org to train Trigonometry

# Simon’s first own code: Archimedean spiral in Processing (Java).

# Forests and Flower Fields

# Spherical Geometry coding challenge

# Simon’s Lectures

This blog is about Simon, a young gifted programmer, who had to move from Amsterdam to Antwerp to be able to study at the level that fits his talent, i.e. homeschool.

Here Simon explains how to calculate the magnitude of a 3D vector. This is something he partially figured out on his own and partially learned from Daniel Shiffman’s tutorial on Trigonometry and Polar Coordinates.

Heard Simon give his Russian grandparents a lecture in the playroom, via FaceTime. When I came in, this is what I saw on the whiteboard. Simon proudly said he figured out how to calculate the arc-tangent. Why, what do you talk to your Grandmom about?

This morning Simon attempted to make a more difficult translation in the Codea app of an example from Daniel Shiffman’s book The Nature of Code (Java) into Lua. It concerned the Gravitational Attraction example from Chapter 2 of the book, Forces. Simon is happy with Codea because “It’s really readable!”, “You don’t need semicolons and parenthesis!” and all logic operators are actually typed in words (“and”, “or”, “not”).

Unfortunately, the function Simon introduced as substitute for mouse pressed release on the touch screen didn’t seem to work:

Simon did successfully translate the simple harmonic motion example from Chapter 3, Oscillation: “I use trigonometry!”

For this example, he had to look up a complex formula for mapping a range to another range on the internet b1 + (s – a1)*(b2 – b1)/(a2-a1) “because map function doesn’t exist in Codea, so I wrote that function”.

Swapping the axes:

Simon created an engine that uses trigonometrical (polar coordinates) formulas to produce beautiful roses. He reproduced the code originally created by Daniel Shiffman from memory and searched for the formulas on Wikipedia.

You can play with this project here (click on the play button to run): https://alpha.editor.p5js.org/simontiger/sketches/HkU9i2h1b

Since Simon has been using so much trigonometry in his programming lately, we decided to review some SOH-CAH-TOA during his regular math classes and did some Brilliant.org quizzes:

Simon also enjoyed building some trigonometric graphs:

This is so exciting! Simon has written his first Java code completely on his own! It’s an animation of the Archimedean spiral (well, we only found out later that it’s actually called this way and that it was already discovered in the 3rd century BC).** **Simon built his spiral playing with polar coordinates in Processing. The first version of the spiral continued to move infinitely, beyond the canvas, so Simon came up with a way to make it stop (used a constrain).

He was so modest as not to say it was his own code and only confessed it tonight when I asked which tutorial or coding challenge this was. “None”, he answered, “I made it up myself”. He then started jumping around with joy. I told him he should post his code on GitHub, which he did. Here is the link: https://github.com/simon-tiger/archimedean-spiral/blob/master/Polar.pde

The following three videos show the making of the spiral step by step, with Simon’s explanations.

Here Simon creates the grid with the x- and the y-axes:

The first version of the spiral that went on forever:

Simon came up with the constrain to control the spiral:

**Archimedean spiral** (aka **arithmetic spiral**), a locus of points corresponding to the locations over time of a point moving away from a fixed point with a constant speed along a line which rotates with constant angular velocity.

The next two videos (in Dutch) are of Simon running Git from command line to show Dad how that works and ultimately placing his code on GitHub. We were quite amazed at his fluent use of BASH, considering he only used Git just once before, approximately a moth ago.

And this is what Simon did afterwards, at 10 pm, as I was trying to finally get him to bed (copying polar shapes formulas from Wikipedia):

He fell asleep asking me what was the γ in those examples…

Simon showed me 3D trigonometrical functions (like tan(x) or cos(x*y*9^10) in his Solve calculator app and we were surprised at their incredible resemblance with forests and flower fields. I mean, is there anyone still doubting we all live in a programmable universe?

Today Simon tried the Spherical Geometry coding challenge from Daniel Shiffman’s awesome channel. It involved programming a globe in Processing (using Java), using trigonometrical equations with longitudes and latitudes.

Here Simon explains the equations:

And shows them inside the code:

And here’s how the challenge went on further:

This is the way the globe looked at the beginning:

Daniel Shiffman explaining the trigonometry behind the longitudes and the latitudes:

Simon got stuck in the middle of the challenge, but made it quite far.

This is what Simon does quite a lot lately – giving prolonged math “lectures” to an imaginable audience or rather, as he confessed, to himself. He stares into the empty space in front of him as he speaks, commenting on what he is about to draw, measure or calculate next. And even though he doesn’t always seem to have mastered the subject quite well (as in the video below with the tangent), one may admire his passion for it. At moments like these (of which there are plenty, mostly late in the evening) we don’t dare remind Simon that all the “normal” children have been tucked in a log time ago.