Profile Picture

Draw XYZ line and then draw a circle perpendicular to the line

Posted By Bruce Guthrie 14 Years Ago

Draw XYZ line and then draw a circle perpendicular to the line

Author
Message
Bruce Guthrie
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 14, Visits: 2

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 label

Dim 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 = True

m_Chart.Enable3D = True

m_Chart.Width = 70

m_Chart.Height = 70

m_Chart.Depth = 70

NChartControl1.Controller.Selection.Add(m_Chart)

' add interlaced stripe to the Y axis

Dim 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 = True

linearScale.StripStyles.Add(stripStyle)

m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale

linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, True)

' add the line

m_Line = CType(m_Chart.Series.Add(SeriesType.Line), NLineSeries)

m_Line.LineSegmentShape = LineSegmentShape.Line

m_Line.DataLabelStyle.Visible = False

m_Line.Legend.Mode = SeriesLegendMode.DataPoints

m_Line.InflateMargins = True

m_Line.MarkerStyle.Visible = True

m_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 values

For i As Integer = 1 To 40 Step 5

m_Line.Values.Add(i)

m_Line.XValues.Add(i)

m_Line.ZValues.Add(i)

Next

' instruct the line series to use x values

m_Line.UseXValues = True

m_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.Line

m_Line1.DataLabelStyle.Visible = False

m_Line1.Legend.Mode = SeriesLegendMode.None

m_Line1.InflateMargins = False

m_Line1.BorderStyle.Color = Color.Blue

m_Line1.BorderStyle.Width = New NLength(3)

'm_Line1.MarkerStyle.Visible = False

m_Line1.Name = "Line Series"

' instruct the line series to use x values

m_Line1.UseXValues = True

m_Line1.UseZValues = True

Dim x As Single = 12

Dim y As Single = 12

Dim z As Single = 12

Dim r As Integer = 2

Dim inc As Integer = 45

' add xy values

For 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))

 

Next

NChartControl1.Refresh()

 

 

i tried various combinations of X,Y,Z calculations but could never get the perpendicular circle.

 

Regards

Bruce

 






Similar Topics


Reading This Topic