arc drawing
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
arc drawing
I think that I may be pushing the limits of Revolution's capabilities here.
I am trying to draw an arc from the 90 degree position to a horizontal straight line that intersects the radius. The problem I have is that the arc ideally should be in the clockwise direction. The solution seemed simple: calculate the point at which the arc touches the horizontal and draw it counterclockwise by subtracting the angle from 90 degrees and using that as the arcAngle.
That seemed to be working fine, until I noticed that for certain values the arc moved away from the 90 degree position. Initially I couldn't figure this out. Then I realised that this started to happen when the radius passed a certain value. Then I realised that the fact that the arcAngle is measured in degrees results in a growing error factor as the radius increases.
If I could calculate the arc in minutes that would give sufficient precision but as far as I'm aware that's not possible
If I could draw the arc in the positive direction the error would not be noticeable, but again as far as I'm aware that's not possible.
Is it time to go back to the drawing board and use a completely different approach?
I am trying to draw an arc from the 90 degree position to a horizontal straight line that intersects the radius. The problem I have is that the arc ideally should be in the clockwise direction. The solution seemed simple: calculate the point at which the arc touches the horizontal and draw it counterclockwise by subtracting the angle from 90 degrees and using that as the arcAngle.
That seemed to be working fine, until I noticed that for certain values the arc moved away from the 90 degree position. Initially I couldn't figure this out. Then I realised that this started to happen when the radius passed a certain value. Then I realised that the fact that the arcAngle is measured in degrees results in a growing error factor as the radius increases.
If I could calculate the arc in minutes that would give sufficient precision but as far as I'm aware that's not possible
If I could draw the arc in the positive direction the error would not be noticeable, but again as far as I'm aware that's not possible.
Is it time to go back to the drawing board and use a completely different approach?
Hi Alistair,
Does it help if you use the property inspector to set the startAngle and the arcAngle both to 180?
Best,
Mark
Does it help if you use the property inspector to set the startAngle and the arcAngle both to 180?
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Mark
I'm not sure how that would help.
The arc is being drawn in the correct position. The problem is that the startAngle is just slightly less (less that one degree) than it should be. Because the radius is so large, the difference is very obvious with some settings. If I were able to draw the arc in the clockwise direction I could use a startAngle of 90. (Am I correct in assuming that there is no way to draw the arc in the clockwise direction?) The end point would still be a little out but this would not be noticeable. However, drawing in the anti clockwise direction both the starting point and the ending point are out.
Regards
Alistair
I'm not sure how that would help.
The arc is being drawn in the correct position. The problem is that the startAngle is just slightly less (less that one degree) than it should be. Because the radius is so large, the difference is very obvious with some settings. If I were able to draw the arc in the clockwise direction I could use a startAngle of 90. (Am I correct in assuming that there is no way to draw the arc in the clockwise direction?) The end point would still be a little out but this would not be noticeable. However, drawing in the anti clockwise direction both the starting point and the ending point are out.
Regards
Alistair
Hi Alistair,
I can draw an arc with any corner I want and in any position I want. I don't understand clockwise and anti-clockwise direction. It isn't animated...?!
Can you tell me step by step what I need to do to see the problem? Perhaps you could show a picture? I guess i just need that quarter to fall down.
Best,
Mark
I can draw an arc with any corner I want and in any position I want. I don't understand clockwise and anti-clockwise direction. It isn't animated...?!
Can you tell me step by step what I need to do to see the problem? Perhaps you could show a picture? I guess i just need that quarter to fall down.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
If I set the startAngle at 90 and the arcAngle to 30 then I will draw an arc from the 12 o'clock position to the 11 o'clock position. If what I want to draw an arc from the 12 o'clock position to the 1 o'clock position I need to setting the startAngle to 60 and the arcAngle to 30.
I thought that I might be able to force the arcAngle to be calculated in the clockwise direction by making it negative (in the example above, -30). Adding -30 to 90 gives 60 which is that angle I want. However, what happens when I do this is that the script compiles but nothing appears.
Why this is important is that I want to draw different arcs from a fixed point round to another point that is less than 90 degrees in the clockwise direction from the original point. I have been doing this by setting startAngle and then calculating the arcAngle as 90 minus the startAngle.
Is that clearer?
I thought that I might be able to force the arcAngle to be calculated in the clockwise direction by making it negative (in the example above, -30). Adding -30 to 90 gives 60 which is that angle I want. However, what happens when I do this is that the script compiles but nothing appears.
Why this is important is that I want to draw different arcs from a fixed point round to another point that is less than 90 degrees in the clockwise direction from the original point. I have been doing this by setting startAngle and then calculating the arcAngle as 90 minus the startAngle.
Is that clearer?
Alisatair,
Your explanation is not clear. How can you set the arcAngle and startAngle before drawing the graphic? Do you draw it with the mouse or by script?
If you have any scripts that do what you describe, post them!!!
Mark
Your explanation is not clear. How can you set the arcAngle and startAngle before drawing the graphic? Do you draw it with the mouse or by script?
If you have any scripts that do what you describe, post them!!!
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
arcAngle and startAngle need to be positive integers. If you do the right calculations you can have your arcs everywhere you want. So for example when the startAngle is 0 and the arcAngle is 60, then you can't just subtract (60*2) from the arcAngle, because that'd be -60. Therefore you need to subtract 60 from 360, and set the startangle to that.
You also need to watch out to not set the angles to more then 360, as that's not allowed either, so be prepared to do lots of calculations if you want to make a catch all handler.
You also need to watch out to not set the angles to more then 360, as that's not allowed either, so be prepared to do lots of calculations if you want to make a catch all handler.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Here is the part of the script where I draw the arc. I suspect that it won't be very easy to follow what I am doing.
reset the templategraphic
set the style of the templategraphic to oval
set the linesize of templategraphic to 1
set the antialiased of templategraphic to true
set the rect of templategraphic to x1-r1, y1, x1+r1, y1+2*r1
set startangle of templategraphic to asinindegrees((r1-h1)/r1)
set arcangle of templategraphic to 90-asinindegrees((r1-h1)/r1)
create graphic "beamPath"
The startAngle is being calculated trigonometrically and the arcAngle is being calculated as the difference between the startAngle and 90.
reset the templategraphic
set the style of the templategraphic to oval
set the linesize of templategraphic to 1
set the antialiased of templategraphic to true
set the rect of templategraphic to x1-r1, y1, x1+r1, y1+2*r1
set startangle of templategraphic to asinindegrees((r1-h1)/r1)
set arcangle of templategraphic to 90-asinindegrees((r1-h1)/r1)
create graphic "beamPath"
The startAngle is being calculated trigonometrically and the arcAngle is being calculated as the difference between the startAngle and 90.
I have found the solution but in doing so have made an interesting discovery.
Asinindegrees returns the equivalent in degrees to an angle in radians. The result wasn't rounded to the nearest degree. Yet is was accepted as a startAngle and in the calculation of the arcAngle. I have now rounded the calculation in the function so that the result is an integer. The sum of the startAngle and the arcAngle sums to 90 and the arc starts at exactly the right point.
The question is: if the startAngle and the arcAngle need to be integers, how was it that setting the startAngle to a value returned by Asinindegrees that was not an integer did not throw up an error?
Anyway, the good news is that the arc now appears just where it should.
Asinindegrees returns the equivalent in degrees to an angle in radians. The result wasn't rounded to the nearest degree. Yet is was accepted as a startAngle and in the calculation of the arcAngle. I have now rounded the calculation in the function so that the result is an integer. The sum of the startAngle and the arcAngle sums to 90 and the arc starts at exactly the right point.
The question is: if the startAngle and the arcAngle need to be integers, how was it that setting the startAngle to a value returned by Asinindegrees that was not an integer did not throw up an error?
Anyway, the good news is that the arc now appears just where it should.
Hi Alistair,
Apparently, they don't need to be integers. I believe co-ordinates, and apparently degrees too, are also accepted if they are no rounded, because usually this makes it easier to write a script that sets coordinates. It just takes out the need for rounding every single value in your script. I find this very convenient, most of the time.
I'm glad you've solved the problem now.
Best,
Mark
Apparently, they don't need to be integers. I believe co-ordinates, and apparently degrees too, are also accepted if they are no rounded, because usually this makes it easier to write a script that sets coordinates. It just takes out the need for rounding every single value in your script. I find this very convenient, most of the time.
I'm glad you've solved the problem now.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode