Solved

Draw perpendicular lines

Posted on 2004-04-15
5
412 Views
Last Modified: 2013-11-20
I need to draw perpendicular lines between two parallel lines .The perpendicular lines have to be drawn with constant distance between them .Two parallel lines could be straight lines or with slope. Known:  begin and end points for two parallel lines.


Thank you.
0
Comment
Question by:shean85
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:caner_elci
ID: 10836246
Here I coded some part of what you want and I think you continue with this:

CPaintDC dc(this);
CPoint pt11( 10, 10 );
CPoint pt12( 100, 100 );
CPoint pt21( 10, 60 );
CPoint pt22( 100, 150 );

dc.MoveTo( pt11 );
dc.LineTo( pt12 );
dc.MoveTo( pt21 );
dc.LineTo( pt22 );

float m = (float)(pt12.y - pt11.y) / (float)(pt12.x - pt11.y);
float alpha = ::atanf( m );
float palpha = alpha + (3.14159f/2.0f);

CPoint basePt;

basePt.x = (pt12.x - pt11.x) / 2;
basePt.y = (pt12.y - pt11.y) / 2;

CPoint pbasePt;
int len = 50;

pbasePt.x = basePt.x + (int)(len * ::cos( palpha ));
pbasePt.y = basePt.y + (int)(len * ::sin( palpha ));

dc.MoveTo( basePt );
dc.LineTo( pbasePt );

0
 
LVL 6

Accepted Solution

by:
joghurt earned 150 total points
ID: 10836319
Though this sounds as a school assignment, we try to give you some help.

* Mathematical background:
Do you know how to calculate the direction of original line(s)?
Do you know how to calculate the direction of the perpendicular lines?
Do you know how to calculate points on the original line(s)?
Do you know how to move a given distance along the original line(s)?

* Programming background:
Do you know how to draw lines in WinAPI (or in MFC)?
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10837701
Though this sounds sarcastic :

Does (s)he have to know?
What's this site for?

(S)he asks for help, because (s)he doesn't know those your counted, or because (s)he is lost in even some radial-degree conversation, or because (s)he wants to have it instead of coding this thing...

Does not matter that much... so, please behave!
0
 
LVL 6

Expert Comment

by:joghurt
ID: 10845389
I just wanted to make things clear. I agree this site is for helping people but it would be nice to know whether he/she stuck in a particular problem in an almost complete program or if we have to explain things from 1+1 being 2.

And you know EE's policy about helping in school assignments. We SHOULDN'T write the whole thing instead of him/her. However, we will gladly help/him in solving any particular troubles or to outline the algorithm, etc.
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10848075
Sure man, that's why I gave a hint, but not the whole code..

Cheers,

Caner
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Smart Camera scanning and reading information 3 122
wait notify demo infinite loop 3 137
tripleUp challenge 7 93
Capture logon name 13 106
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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