Important Question: How to create "otherintersection" between a "functiongraph" curve and the x-axis that i create as "axis"

153 views
Skip to first unread message

nicolap...@gmail.com

unread,
Nov 3, 2015, 7:44:11 AM11/3/15
to JSXGraph
Hello everybody!

I'm developing some graph with JSXGraph, I think it's very awesome!
But now, I'm getting some trouble.
I need to highlight all the intersection points of my "functiongraph" curve with the x-axis.

With "intersection" Element I could get and see only one intersection point, then I tried to use both "otherIntersection" element to draw all the others, but I'm always getting this errorError: 

JSXGraph: Can't create 'other intersection point' with parent types 'object',  'object'and  'object'.
Possible parent types: [circle|line,circle|line,point]

I'm getting this beacuse on what I understood I can draw "otherIntersection" only between two lines, two circles or a line and a circle.

This is the code:
var intersection = board.create('intersection', [xaxis, graph, 1], {withLabel: false});
var otherIntersection = board.create('otherintersection', [xaxis, graph, intersection], {withLabel: false});


Now, how can I draw all the intersection points between my functiongraph curve and the x-axis?

Important:
The functiongraph curve is dynamic, so I can variate the coefficients to let the curve change its x-axis intersection points. 

Thank you so much in advance,
I hope you will help me soon.

Bye
Nick

Alfred Wassermann

unread,
Nov 9, 2015, 7:33:55 AM11/9/15
to JSXGraph
Ordering the intersection points of arbitrary curves and other objects is an inherently difficult problem.

What you can do, is supplying a number which intersection point you want to construct. The number starts with 0, which is also the default value.
That means, your example could look like:

var li = board.create('line', [p,q]);           // Some line
var c = board.create('functiongraph', ["x^2"]); // Graph

var p0 = board.create('intersection', [li, c, 0]); // First intersection point
var
p1 = board.create('intersection', [li, c, 1]); // Second intersection point


Best wishes,
Alfred


nicolap...@gmail.com

unread,
Nov 9, 2015, 7:39:12 AM11/9/15
to JSXGraph
Unfortunately, it doesn't help me, because I don't know why but the second point (p1) is designed over the first point (p0). :(

Se the example with your help here:

Alfred Wassermann

unread,
Nov 11, 2015, 4:36:27 AM11/11/15
to JSXGraph
Your example was very helpful, thank you very much.
The intersection algorithm should be much more stable now, it will appear in the today's nightly build.

Best wishes,
Alfred

Alfred Wassermann

unread,
Nov 11, 2015, 4:43:20 AM11/11/15
to JSXGraph
One more hint reagrding your example: It can be speeded up considerably if you use the attribute "needsRegularUpdate: false" for all the axes and ticks elements. Then these elements are only touched by JSXGraph when zooming.

Best wishes,
Alfred

nicolap...@gmail.com

unread,
Nov 11, 2015, 5:57:11 AM11/11/15
to JSXGraph
Great!
So I'll wait for the new build just to try it out!

Thank you so much!

nicolap...@gmail.com

unread,
Nov 11, 2015, 4:46:02 PM11/11/15
to JSXGraph
Great! 
Now the points are perfectly shown!

I'm only getting some trouble with the right-bottom bar and with negative labels of the axis... 
I'm getting some strange A charachters... can you help me also with this?


Thank you so much!

nicolap...@gmail.com

unread,
Nov 11, 2015, 4:50:00 PM11/11/15
to JSXGraph
Sorry,

I resolved just download the .js file instead of copy and paste it!

:)

Thank you so much!
Very helpful!!

nicolap...@gmail.com

unread,
Nov 14, 2015, 1:04:20 PM11/14/15
to JSXGraph
Hi Alfred,
I've tested my example and after some test I found a bug...

To see it, you could go here http://www.mydevnp01.altervista.org/zanichelli/disequazioni_polinomiali/ , change coefficents to make the graph intersect the x-axis and then just zoom on an intersection point. If you continue to zoom in, after some zooming, you could see that the intersection point is not an intersection point anymore!
It remains on the functiongraph but will leave the x-axis!

I think that it's due to the approximation of the point coordinates! 
In fact, if you go hover the point with your mouse you can see that the x-coordinante recieves a two digits apporximation (ex. 0,62), the y-coordinate instead, should be 0 but became approximated and it's about 0,0292 in the example.

Do you think you could fix it?
I post an image of the bug below.

Thank you so much
Nick

Example image:



Example when mouse hover the point:




















Il giorno mercoledì 11 novembre 2015 10:43:20 UTC+1, Alfred Wassermann ha scritto:

Alfred Wassermann

unread,
Nov 16, 2015, 7:35:33 AM11/16/15
to JSXGraph
OK, I found the bug.
Now it should be much more precise (in the next nightly build).

Best wishes,
Alfred

nicolap...@gmail.com

unread,
Nov 16, 2015, 9:48:12 AM11/16/15
to JSXGraph
Thank you so much, I'll wait for it!

nicolap...@gmail.com

unread,
Nov 17, 2015, 3:44:29 AM11/17/15
to JSXGraph
Sorry mate,

there are other two bugs :(

I hope you will not hate me! :)

Now points are perfectly fixed on the intersection beetwen functiongraph and x-axis, but when i zoomOut too much, remains at least only one intersection point even if there are more intersection and sometimes all points disappear.

The other bug is that when I pass hover the intersection points the y-coordinate should be 0 but I see a great number... You should see it in the image below.

















Thank you so much, I hope you can help me with the usual kindness and speed.
Until now, you really save me! :)

Nick

nicolap...@gmail.com

unread,
Dec 1, 2015, 4:36:21 AM12/1/15
to JSXGraph
Any news?

I fixed the fact that the y-coordinate should be 0 setting the attribute "infoboxDigits:2" at the intersection points.

It remains only the fact that when i zoomOut too much, remains at least only one intersection point even if there are more intersection and sometimes all points disappear, like in the picture below (four intersection, only one point), and when i click and drag the graph, points disappear and re-appear but it should be better if they remains fixed if you say that this is possible.



Can you help me to resolve this two bugs?

Thank you,
Nick

Alfred Wassermann

unread,
Dec 4, 2015, 5:32:54 AM12/4/15
to JSXGraph
Sorry for the delay!
I could make the algorithm even more stable. I hope you give it another try with the next nightly build.
Thanks for your patience and your bug reports,
Alfred

nicolap...@gmail.com

unread,
Dec 7, 2015, 6:43:53 AM12/7/15
to JSXGraph
Hi Alfred, sorry for my fussy, but I've noticed another last little bug... 
when two intersection point are very close, if i click and drag the board, one of them disappear during the dragging, and so it seems that it depends on dragging, so do you think is it possible to fix it and make it stuck on the board even if two points are really close??

Thank you so much
I hope you will not hate me :)

Nick

Alfred Wassermann

unread,
Dec 8, 2015, 5:07:55 AM12/8/15
to JSXGraph
OK, done. The root finding during drag events is much more stable now. The drawback is that plotting during drag events is a little bit slower now, which may be noticable on small devices.
Best wishes,
Alfred

nicolap...@gmail.com

unread,
Dec 8, 2015, 4:16:25 PM12/8/15
to JSXGraph
Great job Alfred!

now it's all really perfect!

Best wishes,
Nick
Reply all
Reply to author
Forward
0 new messages