Results 1 to 7 of 7
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    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
    Jerry

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Find 'corners' (VB6)

    How do you draw the rectangle?

  4. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    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?
    Jerry

  5. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Find 'corners' (VB6)

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

  6. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    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.....
    Jerry

  7. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    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

  8. #7
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    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
    Jerry

Posting Permissions

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