I make a new post out of the one on the scissors cut...
I play with random numbers, points and a circle.
My script aims at cutting an arc from the circle, an arc whose length is defined by two points chosen at random on the perimeter of the circle.
I could manage to define the points like this:
var xorig = Math.random()*20; // x coordinate for the center of circle. var yorig = Math.random()*20; var orig = new Point(xorig, yorig); var theta1 = Math.random() var theta2 = Math.random() var cos1 = Math.cos(theta1); var sin1 = Math.sin(theta1); var cos2 = Math.cos(theta2); var sin2 = Math.sin(theta2); var diffx1 = xorig + cos1*radius; var diffy1 = yorig + sin1*radius; var point1 = new Point(diffx1, diffy1); var diffx2 = xorig + cos2*radius; var diffy2 = yorig + sin2*radius; var point2 = new Point(diffx2, diffy2);
but the when a try to draw a line from the center of the circle to the point on the circle,
var myPath1 = new Path.Line(orig, point1);
either the line comes short of intersecting with the circle, or there's a offset, so it doesn't match.
to cut the circle i used the hitTest fonction. I tried to play with the tolerance number, but i can't get something satisfying. Furthermore, since in the following of the script i loop this kind of "circle-cutting", each and every time it misses the circle, the script doesn't go further...
very often i get a NullPointerException with this line:
var hitResult1 = circle0.hitTest(point1, 5);
so i'm kind of stuck.
any help with precision?
thank you.