## A math challenge...

Ok, so there's this coding language called FCML- a simple language built for a scripting engine in a game (Fantastic Contraption). I'm wanting to write a script that implements the graph of an equation in the form of ax

StaticRect (x1, y1), (x2, y2), z

Where x1 and y1 are coordinates on a Cartesian coordinate plane, x2 and y2 are lengths and widths of the rectangle, respectively, and z is the rotation of the brick. The brick is positioned with respect to it's center; i.e. it's center is positioned with x1 and y1. It's mathematically possible; it's just very confusing for a 7th grader. With a little calculus, trigonometry, and algebra I've come up with these formulas, and would just like to see what others come up with before implementing them.

Input: y=ax

90-tan

10 for y2

root((ax

ax

x - .25 for x1

I'm aiming for an accuracy of 1/2.

^{n}+b to that gaming language. To clarify, this is to create a "level", or a series of bricks, and fitting them along the line of a user-specified equation. The coding language is very simple:StaticRect (x1, y1), (x2, y2), z

Where x1 and y1 are coordinates on a Cartesian coordinate plane, x2 and y2 are lengths and widths of the rectangle, respectively, and z is the rotation of the brick. The brick is positioned with respect to it's center; i.e. it's center is positioned with x1 and y1. It's mathematically possible; it's just very confusing for a 7th grader. With a little calculus, trigonometry, and algebra I've come up with these formulas, and would just like to see what others come up with before implementing them.

Input: y=ax

^{n}90-tan

^{-1}(1/nax^{n-1}) for z10 for y2

root((ax

^{n}-a(x-.5)^{n}) + .25) for x2ax

^{n}+.5(ax^{n}-a(x-.5)^{n}) for y1x - .25 for x1

I'm aiming for an accuracy of 1/2.

active| newest | oldest^{2}+ bx + c if that helps? a, b, and c are constants that give you the different shapes.L

I derived the (now revised) first formula (for z, rotation) by taking the derivitive of the function f(x), which the user defines, take the function of f(x-.5), and subtract the two. That gives me the rise, and the run would be .5. Using that scheme, you can create a triangle of sort. Using the inverse tangent, you can convert (.5 / f(x) - f(x -.5) to degrees; just tan

^{-1}(.5 / f(x) - f(x -.5).For the height of each brick (y2), I just set it as a preliminary number to satisfy itself; this is just aesthetic, and won't play a major factor. For x2, the length of each brick, I used a whipped up a quick formula for calculating the distance it's origin and the start point of the next brick. First, it calculates it's start point: f(x). Then, we calculate the start of the next point: f(x + .5). Using the Pythagorean theorem, we can determine the length is equal to √(f(x + .5) - f(x))

^{2}+ .25.The coordinates are a bit more deceptive, since it's considered the middle of the brick. For x, the most obvious thing to put would be x. But considering the run is .5, we have to add half of that to x to make it where we want it. For the locational x coordinate, I concluded that it should be x + .25. For y, it is much more complicated. The base would be

F(x), but we have to add half the length. We can't use the formula stated above because it's diagonal length; we want purely vertical length. So, we take it before we apply the Pythagorean theorem. Thus concluded; the formula is f(x) + 1/2(f(x + .5) - f(x)).Currently on the road, I have no way of implementing them yet, so I have no way of testing them besides with pen and paper. Which is why I decided posting them here for some peers to revise might be a "resourceful" thing to do.