Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom variable names in equations #93

Closed
ghost opened this issue May 13, 2017 · 2 comments
Closed

Custom variable names in equations #93

ghost opened this issue May 13, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented May 13, 2017

Hi @Maurizzzio, thanks for very useful library!

I watched all previous issues and read all documentation, but I don't found and I don't understand how can I replace the predefined variable names (theta for polar equation or x for linear equation etc.).

Let's say, I want the input to be 2cos(a) instead of 2cos(theta). I know how to define additional variables for equation via scope object, but it's not working for me there.

Thanks!

@mauriciopoppe
Copy link
Owner

mauriciopoppe commented May 13, 2017

Unfortunately for some functions the variable to be used is already defined e.g. for polar equations the variable used is theta, if you want to use other variables in the definition you can always use a function instead of a string e.g.

functionPlot({
  target: '#demo',
  yAxis: {domain: [-1.897959183, 1.897959183]},
  xAxis: {domain: [-3, 3]},
  data: [{
    r: function (scope) {
      const r0 = 0
      const a = 0.5
      const gamma = 0
      const theta = scope.theta
      return r0 * Math.cos(theta - gamma) +
        Math.sqrt(a * a - r0 * r0 * Math.pow(Math.sin(theta - gamma), 2))
    },
//    r: 'r0 * cos(theta - gamma) + sqrt(a^2 - r0^2 * (sin(theta - gamma))^2)',
    fnType: 'polar',
    graphType: 'polyline'
  }]
})

@ghost
Copy link
Author

ghost commented May 17, 2017

Okay, now it's clear for me.

Thanks for reply!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant