• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Drawing ovals, calculating circumference, recording x,y co-ords of along the circumference

I need to be able to generate an oval on a VB form that appears on a slant.  By slant I mean...  The oval will always be taller than it is wide and the top will always be on the left side of the form when compared to the bottom.  Therefore, giving the oval the appearance of being positioned at a 135 degree angle roughly on the screen.

The second part of this is that I need to be able to calculate the circumference of the oval generated so I can make calculations on placing labels around the oval with equal spacing between them.  

The last piece of this is that I need to be able to say that if I want to place a label X number of pixels (unit of measurement is irrelevant and will be determined by the second part of this question) from the top of the oval then the X and Y co-ords for the label will be...

Thanks in advance!  I've been strugggling with this for a while.
0
Xawble
Asked:
Xawble
  • 3
1 Solution
 
Harisha M GCommented:
Hi Xawble,

Try this... (This will draw an Oval of Major Axis 8000, Mino Axis 5000 and angle 135 Deg). This code is specially written for you !!
If you have any doubts, please ask

Private Sub Form_Click()
    Const M_PI = 3.14159265358
    Let incl = 135
    Let mj = 8000
    Let mn = 5000
    Dim x, y, ang As Double
    For ang = 0 To 360 Step 0.05
        x = mj * Cos(ang * M_PI / 180) * Cos(incl * M_PI / 180) - mn * Sin(ang * M_PI / 180) * Sin(incl * M_PI / 180)
        y = -mn * Sin(ang * M_PI / 180) * Cos(incl * M_PI / 180) - mj * Cos(ang * M_PI / 180) * Sin(incl * M_PI / 180)
        PSet (Me.Width / 2 + x, Me.Height / 2 + y)
    Next
End Sub


Bye
---
Harish
0
 
Harisha M GCommented:
If the oval is too large, make mj = 4000 and mn = 2000
0
 
XawbleAuthor Commented:
That's exactly what I am looking for!  I'll just need to play with the numbers a bit to get the proper size and position.  Any idea on how to figure out the circumference of that and space labels out around the circumference?
0
 
Harisha M GCommented:
Well... it depends on the size of the labels you are going to use...

Note that Me.Width/2 & Me.Height/2 specify the centre of the form... and
mj is the major axis, mn is the minor axis.

The height and width of the oval depends naturally on the values of mj & mn.
And the inclination angle is given by incl.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now