Space -> Toggle between positioning the begining/end of the lineLeft Mouse Button -> Hold to position red LineRight Mouse Button -> Hold to position blue LineDownload Attachment: [url="http://vbgamer.strategon.com/msgboard/uploaded/cbx/200371721441_LineIntersect.zip"][img]icon_paperclip.gif[/img]LineIntersect.zip[/url]
5.12 KB">
Finding 2D Line intersections
cbxI have converted the Intersect_Line method to VB.NET. I got the method from the gamedev.net site [url]http://www.gamedev.net/reference/articles/article423.asp[/url] Can some one run the .net lineintersect.exe file I have attached, and report back the results. When the results are displayed do a CTRL+C to copy the text from the msgbox to the clipboard. I am getting the fallowing results ... --------------------------- LineIntersect --------------------------- Calls in 10 Seconds: 38188866 Calls per Second: 3818886.6 Calls per mili Second: 3818.8866 Calls per 30 fps: 127296.22 (per frame) --------------------------- OK --------------------------- The numbers seem to be a little high. (I think there might be an error in the time calculations) So I was wondering what kind of numbers other people will get. I am running a Athlon XP 1600. -------------------------- This is the VB.NET code that I am using to determin the numbers [code] Dim T1, idx As Long Dim x1, y1, x2, y2, x3, y3, x4, y4, retX, retY As Single Randomize(Now.Ticks) x1 = Rnd() * Me.ClientSize.Width : y1 = Rnd() * Me.ClientSize.Height x2 = Rnd() * Me.ClientSize.Width : y2 = Rnd() * Me.ClientSize.Height x3 = Rnd() * Me.ClientSize.Width : y3 = Rnd() * Me.ClientSize.Height x4 = Rnd() * Me.ClientSize.Width : y4 = Rnd() * Me.ClientSize.Height MsgBox("Click OK to start ...", MsgBoxStyle.Information Or MsgBoxStyle.OKOnly) idx = 0 T1 = Environment.TickCount While Environment.TickCount < T1 + 10000 IntersectLines(L1P1.X, L1P1.Y, _ L1P2.X, L1P2.Y, _ L2P1.X, L2P1.Y, _ L2P2.X, L2P2.Y, _ retX, retY) idx += 1 End While MsgBox("Calls in 10 Seconds: " & idx.ToString & vbCrLf & _ "Calls per Second: " & (idx / 10).ToString & vbCrLf & _ "Calls per mili Second: " & ((idx / 10) / 1000).ToString & vbCrLf & _ "Calls per 30 fps: " & ((idx / 10) / 30).ToString & "(per frame)") [/code] How to work the app. ---------------------- 1: To start the speed test press "t" on your keyboard. 2: To position the red and blue lines ... Space -> Toggle between positioning the begining/end of the line Left Mouse Button -> Hold to position red Line Right Mouse Button -> Hold to position blue Line Download Attachment: [url="http://vbgamer.strategon.com/msgboard/uploaded/cbx/200371721441_LineIntersect.zip"][img]icon_paperclip.gif[/img]LineIntersect.zip[/url]
5.12 KB
Eric ColemanThese are the results I get. And I never knew you could use Ctrl+C to copy the text from a message box. I've always retyped the stuff by hand whenever I needed to get the info. Thanks a lot for that tip! I have a 600 Mhz Pentium 3. --------------------------- LineIntersect --------------------------- Calls in 10 Seconds: 26889953 Calls per Second: 2688995.3 Calls per mili Second: 2688.9953 Calls per 30 fps: 89633.1766666667(per frame) --------------------------- The timing code you have is correct, but the "calls per 30 fps" doesn't really mean much. I would be more interested in "time per call," because FPS measurements are not linear.