Results 1 to 7 of 7

Thread: A compass

  1. #1
    bozovilla is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default A compass

    Hi, can I know how do I draw an arrow in a circle which is similar to a compass. But the arrow doesn't have to move around. Thanks

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Drawing the shaft of the arrow would be just a straight line from the center of the circle to the end point. Drawing the head of the arrow would require some computations that will have to be worked out.
    Can you draw a circle?
    Can you draw a line from the center of the circle to the end point?
    Do these first then work on drawing the arrow head.
    There are code examples for drawing on the forum. Use search.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Actually it's not much difficult. Only thing need to identify is about the starting point and the end point of a line, and three lines only need.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    I think drawing the 2 lines that make the head of the arrow will be tricky. That would require some trig to get the angles right.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Not too hard if your trig is good:
    Say you have the arrow 100 pixels long pointing to the right.
    Say the head is to be 10 pixels long.
    Say the angle between the head parts and the shaft is 45 deg.
    Go to the end of the arrow and measuse a 45 deg angle above the shaft and find the point 10 pixels away at that angle and draw a line from the end of the arrow to the above point.
    Do the same for the angle below the shaft.
    Voila you have an arrow with head.

Similar Threads

  1. Compass 1.2 M1
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-14-2007, 08:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •