1. ## Find 'corners' (VB6)

This is a purely academic question as at the moment it has no practical use ( except one of my little projects)

I was showing a colleague the other day how to find the centre of gravity of a compound 2D object ( Just happened to be an L shape with different length arms)

Now this is easy with a pencil and ruler but I was going to see if I could do it in VB6 after a entered different rectangles ( I can do that bit)

What I would like to know is if there is a method whereby once I have drawn a rectangle, I can have automatically calculate the co-ordinates of the 4 corners so I can run off and do my other calculations.

(Don't write an application, as that is for me <img src=/S/grin.gif border=0 alt=grin width=15 height=15> just the method please? I always get confused with the coordinates of corners in VB6

2. ## Re: Find 'corners' (VB6)

How do you draw the rectangle?

3. ## Re: Find 'corners' (VB6)

Using Mouseup and Mouse down, drag and drop...it was in an old tutorial in a VB6 ( I think they called it rubber band.) I would be able to find this just by simple adding and subtracting of the (x1,y1) and (x2,y2) differences

I don't really like that technique though, what if I drop in a shape?

4. ## Re: Find 'corners' (VB6)

Aren't the corners simply (x1, y1), (x2, y1), (x1, y2) and (x2, y2)?

5. ## Re: Find 'corners' (VB6)

Yes, OK I am probably just over complicating things........

I will think about this a bit more as it was an off the top of my head question as I may not be using just rectangles and squares but other polygons. Maybe when I have thought about it and had a bit of graph paper.....

6. ## Re: Find 'corners' (VB6)

Jezza,

Silly question, but how are you planning to define these polygons in the first place?

If you define them as a set of points then you don't need anything more. If you have some process that defines a starting point and then a set of lengths and angles you may have a bit more work to do. If you import them as graphic objects then I guess you're going to have to do some work to decode each graphic format that you plan to import.

StuartR

7. ## Re: Find 'corners' (VB6)

Hi Stuart

You have explained this so much more eloquently than I did. The background to this was that I was having a coffee break this morning and just studying the architecture when I saw the shapes in the buildings and I thought <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15>"There are are some complicated shapes in that building, I wonder how I could find the centre of gravity for each complex shape" (as one does <img src=/S/grin.gif border=0 alt=grin width=15 height=15>)

This spurred me on to ask the question.

Ultimately, yes if I had the co-ordinates of each point then I could just do some trig. dependent on the complexity of the shape. I think for this little exercise I may just use Excel and have a series of XY co-ordinates and then do the maths from there and plot them in a chart.

I am still thinking through the process at the moment but I think for this little exercise creating plot points may be the simpler option and as I develop it think of a method to identify the various corners.

It is a nice problem to ponder

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•