A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: 2D Point Within a 2D Triangle

  1. #1
    FK Newb Beater
    Join Date
    Dec 2002
    Location
    Seattle
    Posts
    676

    2D Point Within a 2D Triangle

    I just thought some of you might like a function that determines if a 2D point exists within a 2D triangle.

    In this case, I have restricted the dragging of an MC to within the bounds of a triangle using this function.

    My next move is to constrain dragging to the outermost edges of a triangle, square, pentagon, etc...

    Anyone able to contribute?
    Attached Files Attached Files
    Just because you changed the code, doesn't mean it's yours

    Most Recent Work:
    Commercial tanning beds website

  2. #2
    #
    Join Date
    Apr 2002
    Location
    berlin - germany
    Posts
    107
    Is this, what you are searching for ?

    http://trashcan.andre-michelle.com/f.../constrain.zip

    try the 'com' version. for convex polygons only.
    Last edited by AndreMichelle; 04-10-2006 at 08:56 AM.

  3. #3
    FK Newb Beater
    Join Date
    Dec 2002
    Location
    Seattle
    Posts
    676
    Sweeettt. I've searched for this far and wide. thank you!

    You are either way above the average intellegence or you have a hekc of a lot of time on your hands....wow!
    Last edited by Sleeve; 04-10-2006 at 12:56 PM.
    Just because you changed the code, doesn't mean it's yours

    Most Recent Work:
    Commercial tanning beds website

  4. #4
    #
    Join Date
    Apr 2002
    Location
    berlin - germany
    Posts
    107
    here is a small bugfix - did you find it ?

    http://trashcan.andre-michelle.com/f...olygon.com.swf
    http://trashcan.andre-michelle.com/f...olygon.com.fla

    no big deal here. I thought about this solution, while thinking about the distance from a point to a polygon. It's the same technic.

  5. #5
    FK Newb Beater
    Join Date
    Dec 2002
    Location
    Seattle
    Posts
    676
    yes, this is no big deal but the other examples on your websites are great. Good work.

    One suggestion if I may.

    Use this.onMouseMove and add a updateAfterEvent() at the end of your function to make it frame rate independent. As you may know, it's a smoother motion at any framerate.
    Just because you changed the code, doesn't mean it's yours

    Most Recent Work:
    Commercial tanning beds website

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