Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: A little schoolboy math (but my schooldays were a long time ago).

by Roger (Parson)
on Feb 01, 2004 at 13:41 UTC ( #325696=note: print w/ replies, xml ) Need Help??


in reply to A little schoolboy math (but my schooldays were a long time ago).

sub solve{ my( $a, $b, $c, $d ) = @_; my( $x, $y ); $x = ($b - $a) / ($d - $a - $c + $b); $y = ($d - $a) * ($b - $a) / ($d - $a - $c + $b) + $a; return( $x, $y ); }

Ok, perhaps more efficiently...
sub solve{ my( $a, $b, $c, $d ) = @_; my $x = ($b - $a) / ($d - $a - $c + $b); my $y = ($d - $a) * $x + $a; return( $x, $y ); }

formula for line 1: Y = (D - A) * X + A formula for line 2: Y = (C - B) * X + B intersection: X and Y coordinates of line1 and line2 are equal ... (D - A) * X + A = (C - B) * X + B reduces to => X = (B - A) / (D - A - C + B) plug X into equation for line 1 gives ... Y = (D - A) * (B - A) / (D - A - C + B) + A


Comment on Re: A little schoolboy math (but my schooldays were a long time ago).
Select or Download Code
Re: Re: A little schoolboy math (but my schooldays were a long time ago).
by davido (Archbishop) on Feb 01, 2004 at 17:37 UTC
    I spend my free time sailing. And despite the fact that GPS's make navigation push-n-click simple, I took an interest in reading through Dutton's Piloting and Navigation cover to cover a couple years ago. I read the 1968 edition, as it came out before GPS, and devotes most of its pages to either Dead Reckoning (deductive reckoning), and Celestial Navigation. BrowserUK's question ignited a lightbulb for me and I flipped open Duttons again to see.

    The short answer is that Roger's answer is accurate. And in fact it employs techniques similar to those used in Dead Reckoning. With Dead Reckoning, one takes a bearing to two known points, and triangulates a position. The cool thing about Dead Reckoning is that if you know your direction and rate of travel, you can take a bearing to only one object of known position, twice at a known interval. Thus, if you get a bearing of 45deg at 10:00am, and 70deg at 10:15am, and you know how far you travelled in that time, and in what direction, you can use your previous position as one of the points of the triangle, the known object as one point, and your current position as one point. It's called a running fix.

    Sorry for delving into this tangent (a pun?) but the subject just kind of got me thinking again. If this followup has a point it's to confirm Roger's methodology.

    Back to your regular scheduled programming, now in progress.


    Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://325696]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-08-29 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (288 votes), past polls