• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing an arrowhead
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing an arrowhead


  • Subject: Re: Drawing an arrowhead
  • From: Thomas Lachand-Robert <email@hidden>
  • Date: Mon, 25 Mar 2002 09:31:25 +0100

Le lundi 25 mars 2002, ` 07:59 , Tobias Haughton a icrit :

The app that I am currently working on draws a NSBezierPath between two objects, the path can be on any angle. The problem I'm having is that I want to draw two lines coming off the end of the bezierPath at a 45 degree angle, in order to form an arrowhead. I thought that I could use NSAffineTransform's rotateByDegrees: and transformBezierPath: methods to do this but it doesn't seem possible. I guess I need to use some geometry equation but I'm clueless when it comes to geometry. Has anybody dealt with this before or have any advice? It would be greatly appreciated.


Let beta = Pi/4 (= 45 degrees) be the inner angle of your arrow.
Assuming that the tip of your arrow is at (x1, y1), that the orientation of the arrow is an angle alpha (use alpha = 0.0 for horizontal arrows, alpha = Pi/2 for vertical upward, etc.) and that the length of the sides of the arrows is a number k (k > 0), the other vertices of the arrows are at
x0 = x1 - k * cos(alpha + beta/2)
y0 = y1 + k * sin(alpha + beta/2)
x2 = x1 - k * cos(alpha - beta/2)
y2 = y1 + k * sin(alpha - beta/2)

You have to draw for (x0,y0) to (x1,y1) then (x2,y2) to get the arrow.

Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Drawing an arrowhead (From: Tobias Haughton <email@hidden>)

  • Prev by Date: Re: Apple and Developers (was lots of different subjects)
  • Next by Date: Re: CMSDA
  • Previous by thread: Drawing an arrowhead
  • Next by thread: OpenGL and Z Buffering with cocoa
  • Index(es):
    • Date
    • Thread