3 Point Arc

Discussion in 'Questions (Windows Mobile)' started by ceaser, May 22, 2008.

  1. ceaser

    ceaser Active Member Licensed User

    Hi All:sign0085:

    How can I in Basic4ppc define 2 points on the screen and then tap on the 3rd point and have an arc (part of a circle) follow the 3rd point as I move my stylus across the screen?

    How do I draw an ellipse?

    How can I zoom in, zoom out and pan my drawing. Remember that the drawing consists of lines, circles, etc that has been defined by coordinates.

    By the way on a scale from 1 to 10, NSBasic gets 1 and basic4ppc gets 10! It's a great development platform. Just waiting to get back to South Africa, so that I can buy a copy and start compiling!

  2. Erel

    Erel Administrator Staff Member Licensed User

    1. You will need to manually draw the arc. There is no DrawArc method.
    2. See ImageLib.DrawEllipse
    3. You can store the drawings data and then redraw all the drawings in a different scale.
  3. colin9876

    colin9876 Active Member Licensed User

    aX2+bX+c !

    Yes Basic4ppc is great. The other day I had to use VB2008 which was a struggle! Micro$oft have a way of making things so complicated. I gave up and went back to Basic4ppc!

    As to drawing an arc, Im sure we could write a small routine to do it.

    I think its a quadratic equation to make an arc.
    Do u want to be able to plot 2 points and then have the 3rd point in between those two (representing the maxima or minima of the curve) ?
    Could easily plot a quadratic through those with a FOR NEXT loop
  4. ceaser

    ceaser Active Member Licensed User


    Yes, I agree with you. I can program in Visual Studio, but what a battle and it slows the PPC down to a snails pace!

    Coming back to the 3 Point Arc. Say I have picked up (Tachy Survey) 3 points on an existing bellmouth which has a radius of say 10m. In the field I will then pick up a point at the start, middel and end of the bellmouth. The bellmouth is not a full circle, but only part of it. I then want to tap on the "ARC" function in my program, tap on the 3 points and the program must then draw an arc (not a full circle) through those 3 points.

    In visual studio one can define the midpoint, radius, color, start angle and end angle of the arc.

    Do you think this is possible?:confused:

    Excuse all my questions!

  5. Erel

    Erel Administrator Staff Member Licensed User

    If you are referring to Graphics.DrawArc then it is not supported on the .Net Compact Framework (which means it can only be used on the desktop).
  6. dennishea

    dennishea Active Member Licensed User

    hi ceaser

    this is what I use to draw an arc.

    Sub DrawArc
    y1 Int(txty1.Text)
    x2 Int(txtx2.Text)
    y2 Int(txty2.Text)
    x2 y2 Then
    For x2 To y2 Step -1
    Round(x1 Cos(cPI 180))
    Round(y1 Sin(cPI 180))
    x2 To y2 Step 1
    Round(x1 Cos(cPI 180))
    Round(y1 Sin(cPI 180))
    End Sub
    x1 and y1 represent center of arc
    x2 represents starting angle
    y2 represents ending angle
    r represents radius

    In a day or two depending on how fast I can document how to use what I have so far and then I will post it all in projects to see if there is any interest in trying make it better then what it is at present.

    I also uploaded a screen capture of a doodle to show what the arcs look like.

    Attached Files:

    • Arc.zip
      File size:
      16.3 KB
  7. colin9876

    colin9876 Active Member Licensed User

    like the picture lol!

    Just a point not great to have x2 y2 representing the angles as x1,y1 are co-ordinates {as expected}.

    having x1,y1 as coords and a1,a2 as the angles would be clearer.

    Also why do you draw these points to a bitmap then draw that rather than just plotting them to a form?
  8. ceaser

    ceaser Active Member Licensed User

    Hi Dennishea:sign0188:

    Thanks a million! It just shows what can be done, if one just uses one's grey matter a bit.

    Thanks Again
  9. colin9876

    colin9876 Active Member Licensed User

    heres my solution

    Sub Draw_Arc(x,y,r,a1,a2,color) 'Angles are in Radians

    s = 1/r
    For i=a1 To (a2-s) Step s
    form1.line(x+r*Cos(i),y+r*Sin(i),x+r*Cos(i+s),y +r*Sin(i+s),color)

    End Sub
    Last edited: May 22, 2008
  10. dennishea

    dennishea Active Member Licensed User

  11. ceaser

    ceaser Active Member Licensed User

    Lets Work Together

    Hi Dennishea

    How about we work together on this "CAD" program? I send you what I have done so far and we can exchange ideas and routines?

  12. dennishea

    dennishea Active Member Licensed User

    Hi ceaser. It is ok by me. Have you had a chance to look at what I've tried so far? I hope we can find better solution for snap to intersection, mid point, end point, ect, ect. The more gray matter the better. Looking forward to working with you ceaser. :)
  13. ceaser

    ceaser Active Member Licensed User

    CAD Program

    Hi Dennishea

    I did not have a change to look at your snap options, I am busy with surveying Stockpiles and checking bolts on a bridge, but I will have a look this weekend and then also send you what I have so far.

  14. dennishea

    dennishea Active Member Licensed User

    Thanks for the quik reply ceaser. Will wait for weekend to get here. Be safe and will type at you later.

    p.s. I will try to program in table for recording. :)
  15. dennishea

    dennishea Active Member Licensed User


    I tried your solution for arc's and I think yours takes longer to draw. I don't know if it's I'm using pixels and your using line or what. Like I have stated in other post's I am not a Programmer so maybe you can help me understand the speed difference. If you get time maybe you could take a look at what I have done so far and point out what I need to do to make the code more ledgeable. There is a link in post 10 that has a zip file with a wordpad file and source code. Thanks for any and all comments. :)
  16. colin9876

    colin9876 Active Member Licensed User


    Yes - unfortunately due to the fact that you cant plot a single point with the .NET libary I have to draw it with connecting lines.
    (form.line(0,0,1,0,cblack) wont draw just one pixel long - this is a flaw in .NET library - smallest lines being 0 points long or 2 pixels long!)

    Its not slow on my device but if you want to speed it up you can double the step line to

    because you dont really need the steps to be as small as 1/r

    I looked at your code and it looks good, no major problems.
    I wouldnt have done it writing to a bitmap because it seems an extra step, but given there is the .NET line bug (that you cant plot a single point) it means there is one advantage of doing it ur way

    Just as a minor critique, on circle you use lable name txtr but this is actually the diameter not the radius so txtdiam would be better name! Thats why u divide it by two when calculating the radius.
    In future I would tighten up the variable naming - as I said before use x,y,x1,y1 etc for co-ordinates but try and use something like l,length,ylen etc etc for lengths. Theres a few places where one minute x,y is a co-ordinate then the next its lengths lol! e.g
    y2 = (y2 / 2) + Min(txty2.Text,txty1.Text)

    ylen might be a clearer variable name here! Other than that its a good start!
    Last edited: May 24, 2008
  17. dennishea

    dennishea Active Member Licensed User

    Hi colin9876. I think the main reason I use very small variables is because I'm not a typist. Erel has done such a good job with basic4ppc that even a bad programmer like me has alot less problems finding his or hers spelling mistakes and I use the term programmer loosely. I hope you keep track of what I'm trying to do and let me know when I can do better. I will go back thru my program and rename my variables with more meaningful names and repost source code. Again thanks very much for your time. :)
  18. agraham

    agraham Expert Licensed User

    You can using the ImageLib library.

    If you're going to bit-twiddle (or pixel-twiddle) don't overlook the "fast" methods in dzts' library http://www.basic4ppc.com/forum/additional-libraries/1403-dzimage-library-3.html#post8181 The not very good (written by me!) help is here dzImage

    Depending upon the amount of pixel work you need doing it could be faster to assign your bitmap to a dztImage Image property, use the FastSetPixel method and then assign your image back. The fast method locks the bitmap for access only at the beginning and unlocks it at the end. ImageLib effectively locks and unlocks it for every pixel access. For many pixels the speed difference could be significant.
  19. colin9876

    colin9876 Active Member Licensed User

    Point taken but Im all for keeping it simple and drawing direct to the screen. Theres no reason to use dlls or bitmaps for this.
    My method is fast if the raw .net line command is used.
    Also I stand by what I said that the .NET line command doesn't follow convention that line(0,0,0,0) should plot a single point if line(0,0,1,0) plots 2

    in fact theres no way I know with .NET to plot a single pixel, the circle fn won't do it either with r=0. Its crazy - there must b a way without using a dll?!
    Last edited: May 24, 2008
  20. klaus

    klaus Expert Licensed User

    Hi ceaser,

    For the 3 point arc, is this what you are looking for ?

    Best regards

    Attached Files:

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice