Jump to content
Sign in to follow this  
Laurent*

Where did I make a mistake. (Simple math)

Recommended Posts

I'm working in java script and I'm having a hard time finding my error. My error started with a var named fx. fx is a math expression and I was sure I did everything correctly but I don't know. fx is a representation of the math expression below. Please help me fix this syntax error. 

lYAbAUv.png

var xcoord = 0;
var ycoord = 100;
var degreeOfRotation = 0;
var degree = (-degreeOfRotation *Math.PI)/180;
var smoother = 10;
var tipAdjuster = 2.8;
var innerDisplacement = -3;

var fx =(
			smoother 
			* 
			Math.pow
			(
				( 
					(	
                      	(-ycoord*Math.sin(degree))+(-xcoord*cos(degree))-xcoord) 
						+ 
						xcoord 
					)
					,
              		tipAdjuster
				)
			)
                

 

Share this post


Link to post
Share on other sites

It doesn't look like you copied the function properly. You've given just one argument to the Math.pow() function because of the parentheses. You're using a sine and cosine, though those aren't part of the equation, and the cosine isn't using the right Javascript function for it. You should make this an actual function that can be reused as well.

I'd need to see more context to know what all the function constants are for.

This is the actual representation of the function Javascript:

var xcoord = 0;
var ycoord = 100;
var smoother = 10;
var tipAdjuster = 2.8;

function f(x) {
  smoother * Math.pow(x + xcoord, tipAdjuster) + ycoord;
}

 

Share this post


Link to post
Share on other sites

Is this what you are trying to do?

a = (-1) * ycoord * Math.sin(degree)
b = (-1) * xcoord * Math.cos(degree)
c = (-1) * xcoord

d = a + b + c
            
smoother * Math.pow(d, tipAdjuster)

Certainly it does not match f(x).

Edited by iwato

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×