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 21 November 2002, 09:01 AM
  #1  
Sub97
Scooby Regular
Thread Starter
 
Sub97's Avatar
 
Join Date: Oct 2002
Posts: 809
Likes: 0
Received 0 Likes on 0 Posts
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
Old 21 November 2002, 09:36 AM
  #2  
MarkO
Scooby Regular
 
MarkO's Avatar
 
Join Date: Oct 1998
Location: London
Posts: 4,891
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

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

Cheers Mark0, much appreciated.
Old 21 November 2002, 03:11 PM
  #4  
Sub97
Scooby Regular
Thread Starter
 
Sub97's Avatar
 
Join Date: Oct 2002
Posts: 809
Likes: 0
Received 0 Likes on 0 Posts
Post

Anyone else got any ideas pleae?
Old 21 November 2002, 03:16 PM
  #5  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
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
Old 21 November 2002, 03:24 PM
  #6  
Barnaby
Scooby Regular
 
Barnaby's Avatar
 
Join Date: Jul 2002
Posts: 320
Likes: 0
Received 0 Likes on 0 Posts
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!
Old 21 November 2002, 03:47 PM
  #7  
MrDeference
Scooby Regular
 
MrDeference's Avatar
 
Join Date: Mar 2002
Posts: 337
Likes: 0
Received 0 Likes on 0 Posts
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?
Old 21 November 2002, 03:54 PM
  #8  
MarkO
Scooby Regular
 
MarkO's Avatar
 
Join Date: Oct 1998
Location: London
Posts: 4,891
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 22 November 2002, 10:56 AM
  #9  
Sub97
Scooby Regular
Thread Starter
 
Sub97's Avatar
 
Join Date: Oct 2002
Posts: 809
Likes: 0
Received 0 Likes on 0 Posts
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
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Abx
Subaru
22
09 January 2016 05:42 PM
PetrolHeadKid
Driving Dynamics
10
05 October 2015 05:19 PM
T.K
General Technical
10
02 October 2015 11:35 AM
the shreksta
Other Marques
26
01 October 2015 02:30 PM
minguela
Wheels And Tyres For Sale
0
29 September 2015 11:28 AM



Quick Reply: C++ Problem



All times are GMT +1. The time now is 09:43 AM.