# 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^{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 z

10 for y2

root((ax^{n}-a(x-.5)^{n}) + .25) for x2

ax^{n}+.5(ax^{n}-a(x-.5)^{n}) for y1

x - .25 for x1

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

Your parabolic equation is y = ax

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

Select as Best AnswerUndo Best Answer

Uhhhh...6? 6.5?

Select as Best AnswerUndo Best Answer

i remember my old algebra teacher, she would always draw parabolas and intend them to look like penises. any teenager would laugh at their math teacher drawing penises in algebra. haha thats the way i remembered the quadratic formula

Select as Best AnswerUndo Best Answer

lmfao.

Select as Best AnswerUndo Best Answer

Wow. That's a pretty freakin awesome algebra teacher.

Select as Best AnswerUndo Best Answer

I get the groundwork of what you are trying to achieve, but I'm not sure how you want the bricks to be positioned. Do you want to make a smooth shape like the graph out of rotated bricks, or just position the bricks along the path as steps? The rotation part is harder, as it involves calculus, but fortunately some simple enough calculus that I can remember how to do :) Could you explain how you derived the last three equations? This sounds like quite an interesting problem. I think with a little messing around I could work out an "accurate" solution (ie fit top edges of bricks to a polygonal approximation of the graph). Where did I put my whiteboard...

Select as Best AnswerUndo Best Answer

I'm aiming to make a smooth or semi-smooth graph, mostly by rotation.

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.

Select as Best AnswerUndo Best Answer

Apparently I made a mistake. In the second sentence, just ignore the "the derivative of".

Select as Best AnswerUndo Best Answer

Wow...I was totally confused after like the second line....I'm sure somebody will help you...maybe kelsehmh( I thinkn i spelled that right) , good luck

Select as Best AnswerUndo Best Answer

Some clarification: make a corresponding graph out of solid rectangles. The rectangles can only be made by the form stated above.

Select as Best AnswerUndo Best Answer

Yeah...ummm, you might as well have been speaking Basque there. Becuase I didn't understand a word you just said.

Select as Best AnswerUndo Best Answer

Uhm. Put simply; make a corresponding graph out of solid rectangles. The rectangles can only be made by the form stated above.

Select as Best AnswerUndo Best Answer