First time posting here but I have been lurking for a couple of months.
Could someone please tell me how I can code the following I am really struggling with it. It is for college just to let ya know so I don't expect anyone to write the code just some help (Well a lot of help to be honest).

I am trying to draw a circle on the visual basic console. I have been told that the console is not made for this but i have to use it.

What I want to do is a circle with:

Centre (40,20)
Radius = 10

I know from basic trig that the following will give me the points on the circle:

x= (10 x CosA)+40
y=(10 x SinA) +20

(A) being an angle in radians.

Then combine x & y that will give me a point on the circle.

I want to use the '' Sets the cursor position
Console.SetCursorPosition(x, y)
Console.Write(".") "

To print a point(.) on the given position from the formulas above.

Now heres my question how do I get Visual Basic too calculate:
x= (10 x CosA)+40
y=(10 x SinA) +20

360 times i.e 0rad-2Pirad and then pass the x & y [(x,y)] point to my cursor position code so that a '.' is printed at that position. I.e I will end up with a circle made out of 360 '.'

I would asume that a loop is used and also an array to store the 360 Pi values.

I'm finding it extremely hard to even get Vb to calculate the Cos of an angle.

I hope i have been as clear as i can and i would really appreciate any help atall even how to calculate the Cos of an angle.

Hi Guys,
Now heres my question how do I get Visual Basic too calculate:
x= (10 x CosA)+40
y=(10 x SinA) +20
...I'm finding it extremely hard to even get Vb to calculate the Cos of an angle.

It would be a lot easier for us to figure out why you are having trouble if you post the code you have tried. Are you sure you are properly converting degrees to radians? It would probably be best to avoid degrees altogether, to be honest. If you want your loop to iterate angles, loop from 0 to 2 * pi with a fractional step.

Code:

' Loop with steps of 1/100ths of a circle
For i As Double = 0 To (2 * Math.PI) Step (2 * Math.PI) / 100

Right guys im back with some of the code i have written their is nothing wrong with the code below it works. Its plotting the circles centre point and a point on that circle at 0 radians. The circles centre point, radius and colour is inputed by the user on the console.

What i want to do is have vb carry out the x and y calculations 360 times (0-2Pi) and then plot each point on the console. Should i use a loop of some sort? All input is greatly appreciated.

Code:

Sub Main()
REM Sets Variables
Dim xOrigin As Integer
Dim yOrigin As Integer
Dim Radius As Integer
Dim CircleColour As String
REM Obtains Data From User
Console.WriteLine("***********************Draw Circle*************************")
Console.WriteLine("")
Console.WriteLine("")
Console.WriteLine("Please Enter The Following Information About The Circle You Would Like To Draw")
Console.WriteLine("")
Console.WriteLine("-Centre Point Cordinates [Please dont Use Negative Values For (x,y)]")
Console.Write(" Enter X Axis Origin: ")
xOrigin = Console.ReadLine()
Console.Write(" Enter Y Axis Origin: ")
yOrigin = Console.ReadLine()
Console.WriteLine("-Please Enter The Radius Of The Circle You Would Like To Draw")
Console.Write(" Radius: ")
Radius = Console.ReadLine()
Console.Write("-What Colour Would Like The circle to be? ")
CircleColour = Console.ReadLine()
Console.WriteLine("")
Console.WriteLine("******The Following Is The Data You Have Entered*******")
Console.WriteLine("Centre Point Of Circle = ({0},{1})", xOrigin, yOrigin)
Console.WriteLine("Radius = {0}", Radius)
Console.WriteLine("Colour= {0}", CircleColour)
Console.WriteLine("Please Hit 'Enter' For the circle to be Drawn")
REM Sin & Cos Calculation
Dim xAngleCosValue As Double = Math.Cos(0)
Dim yAngleSinValue As Double = Math.Sin(0)
REM Point Calculation
Dim xPoint As Integer = (Radius * xAngleCosValue) + yOrigin
Dim yPoint As Integer = (Radius * yAngleSinValue) + yOrigin
REM Plot The Actual Circle
Console.Clear()
Console.SetCursorPosition(xOrigin,yOrigin)
Console.Write("*c")
' Sets the cursor position
Console.SetCursorPosition(xPoint, yPoint)
Console.Write("*")
Console.ReadLine()
End Sub

Below is the part of the code i want to be varied and repeated i.e Vary the Cos and sin calculation and then pass it to the point calculation formula thus passing it to the set cursor position part of the code.

Code:

REM Sin & Cos Calculation
Dim xAngleCosValue As Double = Math.Cos(0)
Dim yAngleSinValue As Double = Math.Sin(0)
REM Point Calculation
Dim xPoint As Integer = (Radius * xAngleCosValue) + yOrigin
Dim yPoint As Integer = (Radius * yAngleSinValue) + yOrigin
REM Plot The Actual Circle
Console.Clear()
Console.SetCursorPosition(xOrigin,yOrigin)
Console.Write("*c")
' Sets the cursor position
Console.SetCursorPosition(xPoint, yPoint)
Console.Write("*")

I think it has been fairly clear from the beginning.
What we don't know is your level of programming experience
And snarfblam showed you how to do the loop.
What part are you actually having problems with?
The Sin and Cos functions (all the angular functions actuallly) expect the angle to be passed in radians, not degrees.
Do you understand what radians are?
Do you know how to create a loop?

In snarfblam's example the loop the variable i would represent the angle, and the angle is generated for 100 points around the circle from 0 to 360.
If you want to do 360 points around the circle, then use 360 instead of 100.
In the loop you would just put the code you have, using the loop variable for the angle (replacing the hardcoded 0 with the angle) since it will change each time through the loop, calculate the point as you do and plot it.

__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET. subscribe