help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any possible optimization?


From: Stewart Dickson
Subject: Re: Any possible optimization?
Date: Mon, 10 Jan 2011 09:41:17 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

Are you finding intersections between pairs of line segments in 2-D?
See: U. Murat Erdem -- Fast Line Segment Intersection
http://www.mathworks.com/matlabcentral/fileexchange/27205-fast-line-segment-intersection

It works in Octave.

Cheers,

-Stewart, http://us.imdb.com/Name?Stewart+Dickson http://www.ifp.uiuc.edu/~sdickson
http://emsh.calarts.edu/~mathart/MathArt_siteMap.html

On 1/10/2011 9:15 AM, Daniel Arteaga wrote:
Hi all

The following function is called many times in my code (always from the same point), and it is actually the bottleneck of the computation:

function [s,t] = intersectionPoint(a,b,c,d)

    % Solve the system of equations
    % (1 - s) ax + s bx = (1 - t) cx + t dx
    % (1 - s) ay + s by = (1 - t) cy + t dy

    A = [ b(1) - a(1), c(1) - d(1); b(2) - a(2), c(2) - d(2)];
    B = [ c(1) - a(1); c(2) - a(2)];

    v = A\B;
    s = v(1);
    t = v(2);

endfunction


Is there any easy way to get a speed increase? Is it worth transforming it into an .oct file? Or maybe including the expressions inline to avoid the function call overhead?

Any suggestion is appreciated.

Thank you very much,

Daniel Arteaga

_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave




reply via email to

[Prev in Thread] Current Thread [Next in Thread]