12,952,215 members (61,506 online)
Rate this:
See more:
i have a crcle having line.i want to do that if we enter numaric value in txt box (0-360). line move to that angle enter in textbox.
issue is how to move circle line in c# code to show angle between 0-360 degree.
Posted 9-Jan-13 2:09am
Updated 9-Jan-13 2:19am
v2
ryanb31 9-Jan-13 8:10am

So, what exactly is your issue? What do you have so far?
rumailamalik 9-Jan-13 8:23am

ma issue is how to move that line acording to input. to show that input 01-360 degree in c#...
ryanb31 9-Jan-13 8:41am

We can't see what code you have; therefore, we can't help you.
rumailamalik 9-Jan-13 9:18am

public void Rotate(int degrees)
{
this.orientation += degrees;

if (this.orientation < 0)
{
while (this.orientation < 0)
{
this.orientation += 360;
}
}
else if (this.orientation >= 360)
{
while (this.orientation >= 360)
{
this.orientation -= 360;
}
}
}
jibesh 9-Jan-13 15:37pm

whats the starting point of the line? from center of the circle?

What is "circle having line"? "Numaric"? "Line move to angle". I understand English is not your native language, but this is not just language, more of a sloppiness. And everyone can use a spellcheck, so wrong spelling is simply impolite...
—SA

Rate this:

## Solution 1

So at this point you have code that ensures your degrees value remains between 0 and 360. Where is your drawing code for the circle? The calculation for deciding where on a circle is a simple parametric equation.
how-do-i-calculate-a-point-on-a-circles-circumference[^]
Circle Equations[^]
v2
Rate this:

## Solution 3

```public Texture2D CreateCircle(int radius)
{
int outerRadius = radius*2 + 2; // So circle doesn't go out of bounds

// Colour the entire texture transparent first.
for (int i = 0; i < data.Length; i++)
data[i] = Color.Transparent;

// Work out the minimum step necessary using trigonometry + sine approximation.

for (double angle = 0; angle < Math.PI*2; angle += angleStep)
{
// Use the parametric definition of a circle: http://en.wikipedia.org/wiki/

data[y * outerRadius + x + 1] = Color.White;
}

texture.SetData(data);
return texture;
}```
v2
Rate this:

## Solution 2

```using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Timers();

namespace WindowsForms
{
public partial class Form1 : Form
{
int circleDiameter;
public Form1()
{
InitializeComponent();
circleDiameter = 100;
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
Point CenterPoint = new Point()
{
X = this.ClientRectangle.Width / 2,
Y = this.ClientRectangle.Height / 2
};
Point topLeft = new Point()
{

X = (this.ClientRectangle.Width - circleDiameter) / 2,
Y = (this.ClientRectangle.Height - circleDiameter) / 2

};

Point topRight = new Point()
{
X = (this.ClientRectangle.Width + circleDiameter) / 2,
Y = (this.ClientRectangle.Height - circleDiameter) / 2
};
Point bottomLeft = new Point()
{
X = (this.ClientRectangle.Width - circleDiameter) / 2,
Y = (this.ClientRectangle.Height + circleDiameter) / 2
};
Point bottomRight = new Point()
{
X = (this.ClientRectangle.Width + circleDiameter) / 2,
Y = (this.ClientRectangle.Height + circleDiameter) / 2
};

e.Graphics.DrawEllipse(Pens.Red, topLeft.X, topLeft.Y, circleDiameter, circleDiameter);

e.Graphics.DrawLine(Pens.Red, CenterPoint, topLeft);

//  e.Graphics.DrawLine(Pens.Black, CenterPoint, topRight);

//     e.Graphics.DrawLine(Pens.Brown, CenterPoint, bottomLeft);

//   e.Graphics.DrawLine(Pens.Orange, CenterPoint, bottomRight);
}

private void timer1_Tick(object sender, EventArgs e)
{

}

}
}```
v2

Top Experts
Last 24hrsThis month
 OriginalGriff 410 CPallini 135 Maciej Los 130 AdvancedDNA 85 RickZeeland 85
 OriginalGriff 6,239 CHill60 3,490 Maciej Los 3,083 Jochen Arndt 1,975 ppolymorphe 1,880