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
551 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
Inequality 4 84
Could you point a workaround on how to open this Adobe Flash documents? 5 166
Slow Printing 8 110
Does a rhombus have 2 pairs of parallel sides 5 99
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
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…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

808 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