Re: Line intersection given 2 point/angle pairs
- From: Aaron Beall <contact@xxxxxxxxxx>
- Date: Tue, 25 Dec 2007 07:44:06 -0800 (PST)
Some people over on the ActionScript3 forum were able to help me out:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=665&threadid=1325165&CFID=11473922&CFTOKEN=38370c4ae773dc3c-FB58AEA2-BA6C-BBB9-195AD23154F870BF&jsessionid=4830d5b1270e32375c54
My final working solution was surprisingly simple:
// this function returns the slope and y-intercept of the line going
thru x,y at angle degrees (as flash measures)
function pointAngleF(point,angle) {
var m = Math.tan(Math.PI*angle/180);
var b = point.x-point.y*m;
return {m:m,b:b};
}
// this function returns the slope and y-intercept of the line going
thru x1,y1 and x2,y2
function pointPointF(p1,p2) {
var m = (p1.y-p2.y)/(p1.x-p2.x);
var b = p1.y-p1.x*m;
return {m:m,b:b};
}
// this function returns the x,y point at the intersection of lines
with slope and y-intercept m1,b1 and m2,b2.
function intersection(m1,b1,m2,b2) {
if (m1!=m2) {
var x = (b2-b1)/(m1-m2);
var y = m1*x+b1;
return {x:x,y:y};
} else {
return null;
}
}
Works perfectly!
On Dec 24, 8:05 pm, Aaron Beall <cont...@xxxxxxxxxx> wrote:
Actually, I can ensure that the angles are facing in a direction such
that they will intersect.
I should also mention that I also have 2 secondary points for both
points, so I can form a line segment for both points if that is more
convenient than an angle. These line segments may or may not contain
the intersection, both cases may occur.
On Dec 24, 7:41 pm, Aaron Beall <cont...@xxxxxxxxxx> wrote:
...as added information, the lines will never be parallel, but I won't
always know in which direction the two will intersect -- ie the known
angles may be pointing away from the intersection point.
On Dec 24, 7:36 pm, Aaron Beall <cont...@xxxxxxxxxx> wrote:
Consider the following:
http://abeall.com/files/temp/vector.intersect.gif
I have two known points, p1 and p2, and with them two known angles, a1
and a2. How would I determine p3?
I've been reading over the FAQ:http://www.faqs.org/faqs/graphics/algorithms-faq/
And really can't figure this out, any help would be appreciated.
- aaron
.
- References:
- Line intersection given 2 point/angle pairs
- From: Aaron Beall
- Re: Line intersection given 2 point/angle pairs
- From: Aaron Beall
- Re: Line intersection given 2 point/angle pairs
- From: Aaron Beall
- Line intersection given 2 point/angle pairs
- Prev by Date: Re: computing diffuse to purely reflective surfaces - how to ?
- Next by Date: Re: Deform path to a bezier path
- Previous by thread: Re: Line intersection given 2 point/angle pairs
- Next by thread: Re: Line intersection given 2 point/angle pairs
- Index(es):
Relevant Pages
|