Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Line intersecting, getting wrong coordinates out from intersection point

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 8th Sep 2014 17:03
Hello I am using RUCCUS code for line intersecting. I get right coordinates for lines intersecting when line 1 is exactly horizontal coming from left or right. I have 8 direction movement. I do get a line intersect true from the other directions but not the right coordinates :-(

It is intX# and intY# that is not coming out right :-P Can anybody with math skills help out?



The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Sep 2014 20:47 Edited at: 8th Sep 2014 23:12
I've never been good with the math, but here is an alternative function that I rely on:



The intersectx# and intersecty# are the location values of the intersection, I just globalize these so I can retrieve them easily after a positive intersection.

I am the one who knocks...
Hotline
15
Years of Service
User Offline
Joined: 22nd Aug 2008
Location:
Posted: 8th Sep 2014 22:39 Edited at: 8th Sep 2014 23:07
Hi This is c++ , but i'm sure you can figure it out how to implement in DBPro :

This is what i use and works perfectly (one of my game's collision detection and physics uses this algorythm)




Some optimisation :
(-s2.x * s1.y + s1.x * s2.y) should be calculated once

[href=forum.thegamecreators.com/?m=forum_view&t=191567&b=5]Spark Particle engine[/href]
[href=forum.thegamecreators.com/?m=forum_view&t=199163&b=5]Transform gizmo plugin[/href]

Login to post a reply

Server time is: 2024-05-12 12:11:33
Your offset time is: 2024-05-12 12:11:33