Re: VB Circle Method Seems to be Seriously Flawed

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Randy Gardner (RandyGardner_at_discussions.microsoft.com)
Date: 01/30/05


Date: Sun, 30 Jan 2005 10:01:02 -0800

Dave:

I placed your code in Command1 and left my code in Form_Load
and I see an error when the center is on +X and -Y. Small but an error.
Below is my Form_Load code for your reference.

The way I find a new radius is by dragging the height of the Arc segment and
the
shorter the height the longer the radius and I place no limits, so the
radius can
get very large, 400>, which magnifies the problem.

Thanks for your response.

Randy

'
' Randy's code
'
Form1.WindowState = 2
Picture1.BackColor = vbWhite
Picture1.AutoRedraw = vbTrue
'
' Set Height unequal to Width, IF EQUAL NO PROBLEM!!!!!!
Picture1.Height = 11000
Picture1.Width = 14000
'
'
' Set Coordinate (0,0) in the center of the picture box.
'
Picture1.ScaleWidth = 130
'
Picture1.ScaleHeight = (Picture1.ScaleWidth / 2) * (Picture1.Height /
Picture1.Width)
'
Picture1.Scale ((Picture1.ScaleWidth * -1) / 2,
Picture1.ScaleHeight)-(Picture1.ScaleWidth / 2, Picture1.ScaleHeight * -1)
'
' Draw Axis at (o,o)
'
Picture1.Line (1 * -1, 0)-(1, 0), vbBlack
Picture1.Line (0, 1)-(0, 1 * -1), vbBlack
'
Exit Sub
'
' End Randy
'

"David Youngblood" wrote:

> "Randy Gardner" <RandyGardner@discussions.microsoft.com> wrote...
> > I think the best solution is the finding of Randy B's and that is to make it
> > square.
>
> That will resolve the issue, but it is not nesessary. With a square control the
> scale aspect ratio will always equal the control aspect ratio. What occurs when
> the control is not square is that the border causes the scale aspect to be *not*
> equal the control aspect. For example,
>
> Width = 200 pixels, Height = 100 pixels
> Height/Width ratio = 100 / 200 = 0.5
> ScaleWidth = 200 - 4(borders) = 196, ScaleHeight =100 - 4(borders) = 96
> ScaleHeight/ScaleWidth ratio = 96 / 196 = 0.4897...
>
> Your code was using the Height/Width ratio when you should be using
> ScaleHeight/ScaleWidth. As long as you maintain and use the proper scale ratio
> there should not be a problem.
> Try this example to see the effect of the borders on aspect ratio,
>
> Private Sub Command1_Click()
> With Picture1
> .Width = .Height * 2
> .BorderStyle = 1
> .Appearance = 1
> Debug.Print "Fixed 3-D border",
> Debug.Print .Width / .Height & " <> " & .ScaleWidth / .ScaleHeight
> .Appearance = 0
> Debug.Print "Fixed Flat border",
> Debug.Print .Width / .Height & " <> " & .ScaleWidth / .ScaleHeight
> .BorderStyle = 0
> Debug.Print "None, no border",
> Debug.Print .Width / .Height & " = " & .ScaleWidth / .ScaleHeight
> End With
> End Sub
>
>
> > I'm going to test that method.
> >
> > As I mentioned I wrote "draw modeling software " for a coumpound bow
> > originally
> > in DOS, VB1. I wrote it as a tool for myself to do bow research since I did
> > not have the facility, machine tools, to do the trial an error design method
> > that the industry uses.
> >
> > I now have interest from one company to buy the software if I can make it
> > more
> > user friendly and current with technology. Besides moving the appliction to
> > VB6
> > I need CAD style editing of the cam design. That is where I am at today.
> >
> > My DOS program was strickly text based editing. In addtion to that I need
> > drag
> > and drop editing. Since the cams design are a series of contiguous arcs the
> > user
> > needs to be able to modify starts, ends and radius to modify the design.
> >
> > I discovered this problem with the circle method when I was modifing the
> > radius.
> > Changing the radius requires a calculations for a new center X,Y. When I
> > calculated the new center and redraw the arc it did not connect with the
> > adjacent arcs when the radius was long, the arc was approaching a line. That
> > evolved in to the testing of the circle method when I could not find a
> > problem with my new
> > center code! Well that is where I'm at today.
> >
> > I think the circle method should work regardless of the shape of the picture
> > box and I believe there is enough evidence to report the problem to Microsoft
> > and hopefully get a fix. We will see!
> >
> > I may check to see how C's circle method works!
> >
> > Always open to suggestions! (randygardner@chartermi.net)
> >
> > Thanks again.
> >
> > Randy G.
> >
> >
> >
> > "Gerald Hernandez" wrote:
> >
> > > > </SNIP>
> > > > There are a number of things you could do to deal with these issues. But
> > > > there is no 1 "right" way. I don't know what your requirements are and
> > > > therefore cannot offer any suggestions. But hopefully I helped more
> > > clearly
> > > > define the problem.
> > > > <SNIP/>
> > >
> > > Ok, I couldn't really leave it there.
> > > To prove my point, I made a couple minor changes to your Form Load code.
> > > Added some variables so you can step through and compare, plus makes it more
> > > readable IMHO.
> > > The primary difference is that I get the inner dimensions of the picture box
> > > instead of the outer dimensions.
> > > Then base the calculations on that ratio. Give this a try and let us know
> > > your results :-)
> > >
> > > Private Sub Form_Load()
> > > '
> > > Dim innerHeight As Single
> > > Dim innerWidth As Single
> > > Dim innerAspect As Single
> > > Dim outerAspect As Single
> > >
> > > Dim fullWidth As Single
> > > Dim fullHeight As Single
> > >
> > > Form1.WindowState = 2
> > > Picture1.BackColor = vbWhite
> > > Picture1.AutoRedraw = vbTrue
> > >
> > > With Picture1
> > > innerHeight = .ScaleY(.ScaleHeight, .ScaleMode, vbHimetric)
> > > innerWidth = .ScaleX(.ScaleWidth, .ScaleMode, vbHimetric)
> > > innerAspect = innerHeight / innerWidth
> > > '^ compare values v
> > > outerAspect = .Height / .Width 'Outside dims, the way it was
> > > End With
> > >
> > > fullWidth = 5! 'Whatever you like
> > > fullHeight = fullWidth * innerAspect
> > > 'fullHeight = fullWidth * outerAspect 'The way it was
> > >
> > > ' Set Coordinate (0,0) in the center of the picture box.
> > > '
> > > Picture1.Scale (-fullWidth / 2, fullHeight / 2)- _
> > > (fullWidth / 2, -fullHeight / 2)
> > > '
> > > ' Draw Axis at (o,o)
> > > '
> > > Picture1.Line (-1, 0)-(1, 0), vbBlack
> > > Picture1.Line (0, 1)-(0, -1), vbBlack
> > > '
> > > End Sub
> > >
> > >
> > >
> > >
>
>
>



Relevant Pages

  • Re: Radius of Arcs
    ... message de news: rbisrael.20090626182125$022d@xxxxxxxxxxxxxxxxxxxx ... Find radius of arcs. ... the width and height of the arc are given. ... StateYehoshua and Yeshua are effectively the same name, ...
    (sci.math)
  • RE: Entering a line offset by an angle from another line
    ... A bit of background on the macro. ... purpose was to place a shape, e.g., a chairs, in a semi-circular arc, evenly ... spaced, with a specified radius. ... from the center of the "circle" to the PinX & PinY of the shape. ...
    (microsoft.public.visio.general)
  • Re: How to draw a simple arc if you know the chord & Radius?
    ... Often I need to draw an arc of which I know ... the chord length and the radius. ...
    (comp.cad.microstation)
  • Re: VB Circle Method Seems to be Seriously Flawed
    ... needs to be able to modify starts, ends and radius to modify the design. ... I discovered this problem with the circle method when I was modifing the ... adjacent arcs when the radius was long, the arc was approaching a line. ... > Dim innerHeight As Single ...
    (microsoft.public.vb.general.discussion)
  • Re: VB Circle Method Seems to be Seriously Flawed
    ... needs to be able to modify starts, ends and radius to modify the design. ... I discovered this problem with the circle method when I was modifing the ... adjacent arcs when the radius was long, the arc was approaching a line. ... > Dim innerHeight As Single ...
    (microsoft.public.vb.general.discussion)