?
Solved

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

Posted on 2005-04-16
4
Medium Priority
?
385 Views
Last Modified: 2008-02-26
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
Comment
Question by:Xawble
  • 3
4 Comments
 
LVL 37

Accepted Solution

by:
Harisha M G earned 2000 total points
ID: 13800050
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
 
LVL 37

Expert Comment

by:Harisha M G
ID: 13800056
If the oval is too large, make mj = 4000 and mn = 2000
0
 

Author Comment

by:Xawble
ID: 13801237
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
 
LVL 37

Expert Comment

by:Harisha M G
ID: 13808607
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question