Wednesday 7 January 2009

Let's talk math again

Right, today we (the whole class, and the whole form) went to the hall to listen to some talks about our personality, co-curriculum and discipline. Well, I got bored, so I started counting on my note book, which was supposed to take down notes from the talks. Lol!

Ok, first off, this post is just for fun, no bragging or boasting intended. If you really hate math, to the extend that you would bang your head against the wall whenever you see math, I suggest you look away.

And, I don't guarantee that my equations are 100% accurate, so, I don't recommend you to use my equations in your daily life. Use the ones you see in your Maths book.

Let's start. I'm not sure how this formula will benefit us. Maybe, it is beneficial in the game development world, but really, I don't know why I even bother with what I'm about to post up.

Anyway, I dunno how to say this, but it's something like How the circle is defined post. But instead of a circle, we are doing a square.

Imagine you have a square and a circle. That square fits perfectly into the circle forming a cyclic quad (the 4 vertices of the square touching the circle)

The width of the square, we will call it w.

w/2 is the distance between the centre of the square (which is also the centre of the circle) to one of the sides of the square, perpendicularly.

x will be the angle, which will be used to calculate all the other variables.

Note that the radius of the circle is the same as the distance between the centre of the square to one of its vertices, which can be easily determine by the Pythagaros' Theorem. When you do that, you should get w/sqrt(2)

Now, L is a little harder to explain.
Imagine you draw a line from the centre to one point on the circumference such that it is at x angle from the red horizontal line shown in the picture. Then, the distance from where that line intersects the edge of the square to the centre is L. And it is this distance that we are interested in.

Right, let's get started. Firstly, we want to find the value of a. To do that, we will take the radius of the circle and subtract it with w/2:

a=w/sqrt(2) - w/2

You should know how to add and subtract fractions with different denominators right?
Anyway, after subtracting the stuff, you should get

a=[w(2-sqrt(2)] / (2 sqrt(2))

Ok, another thing to remember:

L+b=w/2 + a

L+b=radius

Now, we need to experiment a little. Draw a few lines from the centre to the circumference.
Then, (referring to the picture on the right), see the green lines and the pinkish-purplish lines? First, just so you'd know, the red line is for reference. You measure the angle (x) from that red line to one line.

For the green lines, which start from the centre to the edge of the square, we will abbreviate the length of those lines L. And for the pale-purplish lines, their length will be called b.

Through observation, when x=0, 90, 180, 270...,
b is at maximum length. So,
b
= a
b = [w(2-sqrt(2)] / (2 sqrt(2))

or

b = [w(2-sqrt(2)] / (2 sqrt(2)) * 1

And when x=45, 135, 225, 315,...
b = 0

or

b = [w(2-sqrt(2)] / (2 sqrt(2)) * 0

Let's experiment more. We know that, cos 0=1 and cos 90=0. So, how are we going to incorporate it into the above equation?

Anyway, it's very hard to explain. But after testing and testing, it's not that hard to come up with this:

b = [w(2-sqrt(2)] / (2 sqrt(2)) * cos 2x

So, when
x=0, cos 2x=1
x=45, cos 2x=0

But then, when x=90, x=-1. We cannot accept negative numbers. So, we take the absolute value of cos 2x.

And, we will get:

b = [w(2-sqrt(2)] / (2 sqrt(2)) * |cos 2x|

So, now, we have the value of b. To get L, we subtract b from the radius, w/sqrt(2).

L = w/sqrt(2) - b
L = w/sqrt(2) - (
[w(2-sqrt(2)] / (2 sqrt(2)) * |cos 2x| )

Simplify it, and you will get:

L = ( w ( 2 - [2-sqrt(2)] * |cos 2x|) ) / ( 2 sqrt(2) )

I'm gonna keep testing this equation. And if it is flawless, then I should be able to derive the equations that define a square. In the Maths world, there should already be an equation which defines a square, but I prefer to discover it myself.

I have to say though, my equations may not be the best. There may be simpler equations out there. What I have just posted is just the product of my hobby, to discover new equations.

If you have read all the way until here, I admire your patience. Lol!

0 comments: