[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

See 8chan's new software in development (discuss) (help out)
Infinity Next Beta period has started, click here for info or go directly to beta.8ch.net
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


380530 No.3095

So needed an algorithm to detect if 2 lines intersect

SAT doesnt work to well for lines, so i decided to see if i could figure out something myself

Remembered from Geometry class that if a quadrilateral is convex, then its diagonals must intersect, and if its concave, then they dont

So i thought: "if quad(line1point1,line2point1,line1point2,line2point2) is convex, then the lines intersect, otherwise no"

But then i thought: "but wouldnt the 'convex-test' algorithm itself need to test if the diagonals intersect?

Aka:

Line intersection algorithm needs a function to determine whether a quad is concave or not

Concave-test algorithm needs a line intersection algorithm to determine if the quads diagonals intersect

Its a paradox

CPU murdering recursion

Help me

04d4ae No.3098

>>3095

You need to project your lines to the X and Y axis and then check if both projections are intersecting.

That's the most simple method that I know of.


04d4ae No.3099

>>3098

It just came to me that that method *is* the SAT.

>>3095

Why do you think it's not working for lines?

Besides there's one more idea. You can check if the lines intersect analytically i.e. build a standard equations of form y=kx+b for both lines and then check if they have equal results for some x. This can in fact be done without iteration methinks.


4da99e No.3101

3d space or 2d space? Do you actually mean lines or line segments?

If 2d space, just check the slope. They intersect if they aren't parallel.

In 3d space, calculate their closest points. They intersect if their closest point is equal.


7141f1 No.3660

>>3095

something something vectors.

https://www.cs.utah.edu/~jsnider/SeniorProj/BSP1/default.html

has some code that might help you, such as methods that determine wether a point is in front of or behind a plane.


1e9695 No.3671


61d55f No.3685

Think of it like back in highschool algebra.

y=mx+b

if line 1 line 2

collision == true


1e9695 No.3688

>>3685

what about vertical lines?




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]