-
In desperate need of assistance...
I need some help with figuring out a piece of functionality that I just can't
get. What I want to do is be able to add a "terminator" to the lines that
I draw in my view. The terminator is supposed to be perpindicular to the
original line and should be a set length for every line in the window that
is drawn. I've gone back to my old calculus books looking up formulas and
equations for circles, intersection points, etc... but have had little luck
implementing it. I get it to work, but depending on the slope of the various
lines, the terminators have different lengths and are, more often than not,
not perpindicular to the original line. If anyone has ANY thoghts about
how I might accomplish what I'm trying to do, please let me know. I'm in
a bind and need some assistance as soon as possible. If you think you might
be able to help and need more information you can email me and I'll do my
best to explain it better.
Thanks in advance.
-
Re: In desperate need of assistance...
Given a line A=(X0,Y0)(X1,Y1) we want B=(X2,Y2)(X3,Y3) such that B is perpendicular
to A, intersects A at (X1,Y1)=((X2+X3)/2,(Y2+Y3)/2) and is of length C
1) Get the line as a vector
Xv = X1 - X0
Yv = Y1 - Y0
2) Get a perpendicular vector by reflection
Xp = Yv
Yp = Xv
3) Make the vector one half of C in length
X' = ( Xp / sqrt( Xp * Xp + Yp * Yp )) * C / 2
Y' = ( Yp / sqrt( Xp * Xp + Yp * Yp )) * C / 2
4) Calc the end points for line B
X2 = X1 + X'
Y2 = Y1 + Y'
X3 = X1 - X'
Y3 = Y1 - Y'
Hope that helps...
Steve
"BeefStew" <scrasch@aol.com> wrote:
>
>I need some help with figuring out a piece of functionality that I just
can't
>get. What I want to do is be able to add a "terminator" to the lines that
>I draw in my view. The terminator is supposed to be perpindicular to the
>original line and should be a set length for every line in the window that
>is drawn. I've gone back to my old calculus books looking up formulas and
>equations for circles, intersection points, etc... but have had little luck
>implementing it. I get it to work, but depending on the slope of the various
>lines, the terminators have different lengths and are, more often than not,
>not perpindicular to the original line. If anyone has ANY thoghts about
>how I might accomplish what I'm trying to do, please let me know. I'm in
>a bind and need some assistance as soon as possible. If you think you might
>be able to help and need more information you can email me and I'll do my
>best to explain it better.
>
>Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks