flat assembler
Message board for the users of flat assembler.

Index > Heap > [ARTICLE]Circle-triangle intersection method

Author
Thread Post new topic Reply to topic
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Another one of my articles.. as the name suggests, this one's about circle-triangle intersection. It's not really FASM-related (i.e it uses pseudo-code), that's why I post it into heap. Anyway, I do recommend to "optimize" it in assembly when you finish the design phase.

I wanted to add it to http://www.devmaster.net, but I tried twice and never got any feedback from them. I suppose it wouldn't hurt anyone if I also host it here (i.e post attachment). I apologize if it hurts Smile

I would like to know what you think of it.. Is it easy to understand, hard? I want easy, since I like math, but sometimes the mathematical descriptions are just too heavy. Math is the logic, but a bit of "human" sense always helps since we're not robots, and diagrams also help a lot.

BTW: do you think it's better to put this in Projects and Ideas section?

Happy coding Wink Smile

PS: Replace .txt extension with .chm after download. dunno why it doesn't support .chm extension


Description:
Download
Filename: Circle-Triangle intersection method.txt
Filesize: 57.02 KB
Downloaded: 238 Time(s)



Last edited by Borsuc on 28 Oct 2006, 11:46; edited 1 time in total
Post 19 Oct 2006, 16:38
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Any suggestions as to where to add this article (i.e like devmaster, etc).. GameDev seems a bit hellish -- it needs to be there for at least 30 days, and after that can I put it on other sites. More friendly hosts out there?
Post 19 Oct 2006, 17:32
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
I really need to learn vectors again Laughing

I found it a bit tough to follow, but I pretty much understood what was going on Laughing
Post 28 Oct 2006, 11:32
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Updated version, with a new optimization: eliminates the division with a multiplication Wink

cod3b453 wrote:
I found it a bit tough to follow, but I pretty much understood what was going on
Where was tough part? Were the diagrams not helpful? Please explain so I can improve Smile
Post 28 Oct 2006, 11:48
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
sorry, I was a bit breif...

The pictures were helpful, the tough bits were probably my lack of knowledge. The main area I had trouble understanding was how the + and - regions were determined from the normals in part 2.
Post 28 Oct 2006, 13:02
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
The + is when the "point" is on the side of the normal, and - when it's on the opposite side (i.e the normal has a direction (horizontal) and a sense (left/right), so if it's facing left, then any points left from it will be positive and right from it will be negative).

In the article, look at the first diagram at part 2, and then analyze the following statement (with a, b and c). An example is also explained there. Imagine a, b and c are 3 points, and the normal N's facing is where the arrow points (kinda like south-west in the diagram).

If you have suggestions as to whether I should modify that to make it more precise, please tell me Smile
Post 28 Oct 2006, 13:30
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
yeah I understand the principle, but I still don't see how the normal will always point into the triangle or how you can check if it is or not without more calculation or explaination.
e.g.
Code:
; |\    ¯|        How do we know that this 
; | \  /          cannot happen?
; |  \/           (sorry for the rubbish ASCII art)
; |-> \
; |  ^ \
; |__|__\
    
Post 28 Oct 2006, 14:27
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
I understand your confusement. However, it's the arrangement of your vertices that does this. That is, in the article, it says you must have them in clockwise order, so the normals will point inward. Remember that the order in which you store them is important -- and it is specific for your needs. Thus you "choose" the method (clockwise or counter-clockwise).

There's also a tip of how to "reverse" the sign of the equation if you have them in counter-clockwise order, so they will still point inward.

Here's my ASCII diagram:

Code:
CLOCKWISE ORDER (A,B,C)
  A
  |\
  | \  \
^ |  \  \
| |   \  _|
| |    \
| |     \
  |      \
  |_______\
  C       B
    <--    


Code:
COUNTER-CLOCKWISE ORDER (A,B,C)
  A   _
  |\ |
  | \  \
| |  \  \
| |   \
| |    \
\/|     \
  |      \
  |_______\
  B       C
     -->    


The reason I didn't explain this in the article is because this is quite a basic stuff used in many 3D things. It's the order of your vertices (v1 to v2 to v3, and back to v1) that matters when you make the normals. If it's in clockwise order, use the standard equations to get the normals pointing inward. If it's in counter-clockwise order, use the flipped signs of the equations to get the normals pointing inward. It is specific and you "choose" it how you want it to be Wink

Hope it's clear
Post 31 Oct 2006, 11:43
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
aaahhhhhh Embarassed Rolling Eyes

lol I got 2 vector tests coming up too Laughing
Post 31 Oct 2006, 12:07
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.