hello
i have a problem that i cannot quite resolve.
i have a simple XYZ Scatter line in a 3D chart, i then want to draw a circle, i use a smooth line series for this, at a point on the line, but i want the circlw to be perpendicular to the line.
here is some code i tried but i could never quite get the perpendicluar circle, i could get close but not perpendicular. i am sure it is just some basic maths that i am missing. maybe some one out there can point out my error.
i draw a basic XYZ scatter line as follows.
' add a header labelDim header As NLabel = NChartControl1.Labels.AddHeader("XY Scatter Line Chart")header.TextStyle.FontStyle =
New NFontStyle("Times New Roman", 18, FontStyle.Italic)header.ContentAlignment = ContentAlignment.BottomRight
header.Location =
New NPointL(New NLength(2, NRelativeUnit.ParentPercentage), New NLength(2, NRelativeUnit.ParentPercentage))NChartControl1.Controller.Tools.Add(
New NTrackballTool())' apply predefined projection and lighting'm_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted)'m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights)m_Chart = NChartControl1.Charts(0)
m_Chart.Axis(StandardAxis.Depth).Visible =
Truem_Chart.Enable3D =
Truem_Chart.Width = 70
m_Chart.Height = 70
m_Chart.Depth = 70
NChartControl1.Controller.Selection.Add(m_Chart)
' add interlaced stripe to the Y axisDim linearScale As NLinearScaleConfigurator = New NLinearScaleConfigurator()Dim stripStyle As NScaleStripStyle = New NScaleStripStyle(New NColorFillStyle(Color.Beige), Nothing, True, 0, 0, 1, 1)stripStyle.SetShowAtWall(ChartWallType.Back,
True)stripStyle.SetShowAtWall(ChartWallType.Left,
True)stripStyle.Interlaced =
TruelinearScale.StripStyles.Add(stripStyle)
m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale
linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back,
True)' add the linem_Line =
CType(m_Chart.Series.Add(SeriesType.Line), NLineSeries)m_Line.LineSegmentShape = LineSegmentShape.Line
m_Line.DataLabelStyle.Visible =
Falsem_Line.Legend.Mode = SeriesLegendMode.DataPoints
m_Line.InflateMargins =
Truem_Line.MarkerStyle.Visible =
Truem_Line.BorderStyle.Color = Color.Red
m_Line.MarkerStyle.PointShape = PointShape.Cylinder
m_Line.MarkerStyle.Width =
New NLength(1.5F, NRelativeUnit.ParentPercentage)m_Line.MarkerStyle.Height =
New NLength(1.5F, NRelativeUnit.ParentPercentage)m_Line.Name =
"Line Series"' add xy valuesFor i As Integer = 1 To 40 Step 5m_Line.Values.Add(i)
m_Line.XValues.Add(i)
m_Line.ZValues.Add(i)
Next' instruct the line series to use x valuesm_Line.UseXValues =
Truem_Line.UseZValues =
True
then on a button click i attmept to draw my circle perpendicular to the line at point 12,12,12 with radius of 2. my line has an angle of 45 degrees.
' add the line
m_Line1 =
CType(m_Chart.Series.Add(SeriesType.SmoothLine), NSmoothLineSeries)'m_Line1.LineSegmentShape = LineSegmentShape.Linem_Line1.DataLabelStyle.Visible =
Falsem_Line1.Legend.Mode = SeriesLegendMode.None
m_Line1.InflateMargins =
Falsem_Line1.BorderStyle.Color = Color.Blue
m_Line1.BorderStyle.Width =
New NLength(3)'m_Line1.MarkerStyle.Visible = Falsem_Line1.Name =
"Line Series"' instruct the line series to use x valuesm_Line1.UseXValues =
Truem_Line1.UseZValues =
TrueDim x As Single = 12Dim y As Single = 12Dim z As Single = 12Dim r As Integer = 2Dim inc As Integer = 45' add xy valuesFor i As Integer = 0 To 360 Step 5'm_Line1.Values.Add(y + r * Math.Sin(Math.PI / 180 * i))m_Line1.Values.Add(y + r * Math.Sin(Math.PI / 180 * (inc + i)))
m_Line1.XValues.Add(x + r * Math.Cos(Math.PI / 180 * i))
m_Line1.ZValues.Add(z + r * Math.Cos((Math.PI / 180) * (i + 180)))
'm_Line1.ZValues.Add(z + r * Math.Sin((Math.PI / 180) * i))
NextNChartControl1.Refresh()
i tried various combinations of X,Y,Z calculations but could never get the perpendicular circle.
Regards
Bruce