Solved

Given a point, slope and length, find another point 45 degrees from the original with a certain length

Posted on 2011-03-23
2
552 Views
Last Modified: 2012-05-11
Background:
I have a viewer application that displays images. One feature that I have added is the ability to draw annotations onto the image. One of the annotations that I would like to draw is a pointer (arrow) annotation so users can add focus to certain parts of the document.

What I have so far:
Breaking this down my annotation is really nothing more than a line drawn from the Starting Point (S) to the Ending Point (E) with two additional lines being drawn from S to two new points (P1, P2) where the lines S->P1 and S->P2 come off of point S at 45 degrees.

Additionally, I want my arrow head to grow and shrink with the size of the annotation, so what I have done is find the midpoint (M) of Line S->E, and then find the midpoint of line S->M to find the "Quarter point" (Q) which should be exactly one fourth of the given line S->E. If I draw a perpindicular line through point Q (the thin blue line) I know that point P1 and P2 should lie on that line. I also know that lines S->Q, Q->P1, and Q->P2 should all have the same length.

Question:
How do I find the points P1 and P2? I have attached a diagram to further explain my problem. The dashed red lines are the lines I hope to draw. Diagram
0
Comment
Question by:PaperlessEnvironments
2 Comments
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 500 total points
ID: 35202113
All you need is S and E and it's easy
M.x = (E.x+S.x)/2
M.y = (E.y+S.y)/2

Q.x = (M.x+S.x)/2
Q.y = (M.y+S.y)/2

 diagramIf you look at this image, you can see that P2.y - Q.y = Q.x - S.x so

P2.y = Q.y + (Q.x - S.x)
P2.x = Q.x + (S.y - Qy)
P1.y = Q.y - (M.x - Q.x)
P1.x = Q.x - (Q.y.- M.y)
0
 

Author Closing Comment

by:PaperlessEnvironments
ID: 35202532
You rock. My mind was too far down the wrong track. Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
Learn how to download your full Prezi presentation for offline presenting. Prezi doesn’t have to be viewed and shared in a web browser, even with a free account you can download your full presentation to share with others. Be sure to download any vi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question