Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

C++ Problem

Thread Tools
 
Search this Thread
 
Old Nov 21, 2002 | 09:01 AM
  #1  
Sub97's Avatar
Sub97
Thread Starter
Scooby Regular
 
Joined: Oct 2002
Posts: 809
Likes: 0
Post

Hi Guys,

I have a problem in C++ and I was wondering if any of you had any ideas please.


I have to allow the user to click points on the screen the points join up to form a polygon of any size. The program then needs to store the co-ordinates of the points and prints out a list. It also needs to store the lengths of the lines between the co-ordinates and print them out in a list.

Any thoughts welcome.

Cheers,

Steve
Reply
Old Nov 21, 2002 | 09:36 AM
  #2  
MarkO's Avatar
MarkO
Scooby Regular
 
Joined: Oct 1998
Posts: 4,891
Likes: 0
From: London
Thumbs up

Check out the 'Scribble' example in MSDN. It's a tutorial which describes steps to do something very similar.
Reply
Old Nov 21, 2002 | 10:16 AM
  #3  
Sub97's Avatar
Sub97
Thread Starter
Scooby Regular
 
Joined: Oct 2002
Posts: 809
Likes: 0
Post

Cheers Mark0, much appreciated.
Reply
Old Nov 21, 2002 | 03:11 PM
  #4  
Sub97's Avatar
Sub97
Thread Starter
Scooby Regular
 
Joined: Oct 2002
Posts: 809
Likes: 0
Post

Anyone else got any ideas pleae?
Reply
Old Nov 21, 2002 | 03:16 PM
  #5  
GaryK's Avatar
GaryK
Scooby Regular
 
Joined: Sep 1999
Posts: 4,037
Likes: 0
From: Bedfordshire
Post

Sub,

what IDE do you use? Ask cos if its BC++B theres a **** load of components for Delphi/BCB and I found something that would do most of what you want in 5 mins flat but no good if your a VC++ man!

Gary
Reply
Old Nov 21, 2002 | 03:24 PM
  #6  
Barnaby's Avatar
Barnaby
Scooby Regular
 
Joined: Jul 2002
Posts: 325
Likes: 0
Post

I had a test at an interview on something like that a few years back.

I can't remember the details, but the answer involved doing something clever with the area under each pair of points and checking if the imaginary line between each pair of points crossed the drawn line.

It was quite complicated and the guy explaining it was a mathematician!
Reply
Old Nov 21, 2002 | 03:47 PM
  #7  
MrDeference's Avatar
MrDeference
Scooby Regular
 
Joined: Mar 2002
Posts: 337
Likes: 0
Post

MarkO is bang on.
The easiest way is to butcher something like Scribble. Use the mouse coordinates from OnMouseDown (or whatever the event is) normalise them to the client window and store them in an array of Points (either MFC or cut your own). Then the rest is Pythagoras.
If you can't use MFC, however, then you may have difficulties using Scribble.
What's giving the trouble?
Reply
Old Nov 21, 2002 | 03:54 PM
  #8  
MarkO's Avatar
MarkO
Scooby Regular
 
Joined: Oct 1998
Posts: 4,891
Likes: 0
From: London
Post

I actually did this in my algorithms course at Uni, but that was over 10 years ago, so I can't remember the name of the "is a point inside a region" algorithm.

However, as usual, a quick and simple web search came across this which seems to be a good and simple way of determining if a point is within a polygonal region.
Reply
Old Nov 22, 2002 | 10:56 AM
  #9  
Sub97's Avatar
Sub97
Thread Starter
Scooby Regular
 
Joined: Oct 2002
Posts: 809
Likes: 0
Post

Thanks for all the help guys.

Its for my brothers misses, shes doing C++ at uni and wanted my help, I do VB and C mainly at work, so I didnt know exactly how to help her.

GaryK - she is using Borland C++. I had a quick look at it today and I think I should be able to sort it all out for her know.

Thanks again.

Steve
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Abx
Subaru
22
Jan 9, 2016 05:42 PM
PetrolHeadKid
Driving Dynamics
10
Oct 5, 2015 05:19 PM
T.K
General Technical
10
Oct 2, 2015 11:35 AM
the shreksta
Other Marques
26
Oct 1, 2015 02:30 PM
minguela
Wheels And Tyres For Sale
0
Sep 29, 2015 11:28 AM




All times are GMT +1. The time now is 01:05 PM.