LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot circle with known radius and origin in XYGraph

Is there any method to draw curves or circles in XYGraphs with known radius and origin.
0 Kudos
Message 1 of 7
(21,936 Views)
Only if you know the curve formula, as circle is (X-x0)^2+(Y-y0)^2=R^2 you just have to implement this. Attached there's an example. I recommend you to see how it is done and think in other ways, cos it's the first sollution that came to my mind.
Hope this helps
0 Kudos
Message 2 of 7
(21,936 Views)
Sorry, I made some kind of mistake, center coordenates are not well done. Hope the concept gave you an idea.
0 Kudos
Message 3 of 7
(21,936 Views)
Use the formulas:
X = R cos(Theta) + Xo, Y = R sin(Theta) + Yo
to generate a set of points. The step size of Theta will affect how solid your circle is.

To plot them, you will need to initialize an empty 2D array, then fill in the spots for each point.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 7
(21,936 Views)
This code might help for plotting Circle or Arc
0 Kudos
Message 5 of 7
(21,936 Views)
This code might help for plotting Circle or Arc
Please declare conpi as singe
and value 4*atn(1) in vb
or user 22/7
0 Kudos
Message 6 of 7
(21,936 Views)
This code might help for plotting Circle or Arc
Please declare conpi as single
and value 4*atn(1) in vb
or user 22/7
use this code
Sub PlotCircle(graph As CWGraph, StartAngle As Single, endAngle As Single, radius As Single, H As Single, k As Single)
Dim i As Integer
Dim epoint As Integer
Dim xdata() As Double
Dim ydata() As Double
Dim radd As Single
Dim j As Integer
dim conPi as single
conpi=4*atn(1) ' or 3.14
' H , k Is center of circle and rad is radius
If StartAngle >= endAngle Then
radd = endAngle - StartAngle + 360
Else
radd = endAngle - StartAngle
End If
If radd < 0 Then radd = radd * (-1)
ReDim xdata(0 To CInt(radd))
ReDim ydata(0 To CInt(radd))
j = 0

For i = 0 To CInt(radd)
xdata(j) = H + radius * (Cos((StartAngle + i) * (conPI / 180)))
ydata(j) = k + radius * (Sin((StartAngle + i) * (conPI / 180)))
Next
graph.Plots(graph.Plots.count).PlotXvsY xdata, ydata
End Sub
0 Kudos
Message 7 of 7
(21,936 Views)