A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: How to draw the normal to line

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    14

    How to draw the normal to line

    I have the line that slope on some angle. How I can draw normal to the end of line?

  2. #2
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    Not sure what you mean. Why don't you draw a picture and post it?

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Posts
    14
    Well. How I can calculate normal vector to line?

  4. #4
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    A line has two normal vectors, pointing in opposite directions.

    If you know the angle of the line (theta) in radians, the angles of the normal vectors are:
    theta+PI/2
    theta-PI/2

    Or if you know the slope of the line (m), the slope of the normal line is -1/m.
    Last edited by Nialsh; 04-14-2010 at 04:49 PM. Reason: oops, it's pi/2 not pi

  5. #5
    Junior Member
    Join Date
    Nov 2008
    Posts
    14
    Is there a way avoid to calculate angles? I need just normalized normal vector (i e vector that has length 1).

  6. #6
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    How is your line defined? Is it a line segment formed by two points?

  7. #7
    Junior Member
    Join Date
    Nov 2008
    Posts
    14
    Of course yes. B/c I need to draw its with Flash draw API.

  8. #8
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    If you points are A and B, your normals are:
    <By-Ay, Ax-Bx>
    <Ay-By, Bx-Ax>

  9. #9
    Junior Member
    Join Date
    Nov 2008
    Posts
    14
    Great thanks!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center