Open Happypig375 opened 6 years ago
Related parameters in my above incomplete form should be used with setFunction:
nerdamer.setFunction("func", ["x", "y=40-x"], "x+log(y)");
line(pt1: [1,2],slope: 1)
I definitely like the idea of having named parameters, especially the proposed syntax. I'm not too worried about ambiguity but more about the difficulty of implementation using the current parser.
Question: Should line also create parabolas etc?
I don't know. Provide me with examples of where this is done or a proposal of how this can be supported and we'll give it a go.
Currently line is in Algebra.js, maybe factor it and the new functions into a new Geometry.js (needs to depend on Solve.js as calculating shape intersections etc. requires Solve.js)?
Adding a geometry package shouldn't be a problem. The line function can technically be in the core since it has no dependencies but we can hash this out.
Should line also create parabolas etc?
Just thought of an ambiguity: https://www.wolframalpha.com/input/?i=parabola+through+(1,2),(2,1),(3,3)+and+hyperbola+through+(1,2),(2,1),(3,3) Maybe separate functions for parabolas and hyperbolas.
the difficulty of implementation using the current parser
What about adding this during the rewrite of the parser in the upcoming 0.8.0?
@Happypig375 I'm still looking at options for 0.8.0 so I'll be keeping this issue in mind.
A couple of questions to discuss:
I prefer 1 over the rest, then 2, then 3.
The design above is super incomplete. But it can for example link the area parameter to the 3 side parameters in the triangle function (also not to confuse with the triangular function, aka tri).
I see that matrices and vectors in nerdamer are imported from Sylvester. Although it is basically dead, it still has some nice Geometry functions. Can import function ideas from there.
(The three 3s special issue! :tada: :clap:)
Take line as an example. Not every time two points are specified, sometimes a point and slope is given. Now line cannot be used. How are we going to solve this? Extend the parameter list?
Usage:
Now this is ugly and ambiguous.
Named parameters will make this better:
I have thought of a few proposals of this syntax (I prefer 1 and 2):
function(param=value)
Pro: Looks natural Con: Ambiguity with equationsfunction(param: value)
Pro: Looks natural Con: Ambiguity with ratiosfunction({param: value})
Pro: Literally familiar JSON Con: Looks unlike mathfunction{param: value}
Pro: Less excess parentheses than 3, looks more natural than 3 Con: Not look like mathfunction{param=value}
Pro: The look is on par with 4 Con: Still not look like mathRelated parameters:
Helps implementing the below.
The above proposals will greatly benefit the following proposal: More Geometry functions extend line function with these arguments:
And new functions:
rectangle(leftup, leftdown, rightup, rightdown, length, width, perimeter, area, rotation) circle(centre, diameter, circumference, area, circumpoint1, circumpoint2, circumpoint3) triangle(point1, point2, point3, side1, side2, side3, angle1, angle2, angle3, perimeter, area) area(equation) perimeter(equation) vertexes(equation) These are the main ones for now, will add more later.
Question: Currently line is in Algebra.js, maybe factor it and the new functions into a new Geometry.js (needs to depend on Solve.js as calculating shape intersections etc. requires Solve.js)? Probably yes
Thanks for reading (and implementing).