Page 1 of 1
Lines between 3D points?
Posted: Sat Mar 18, 2017 3:10 am
by 16579481
I have a TPoint3DSeries and I would like to draw lines between various pairs of points (not just connect them in sequence). What is the best (simplest) way? For 2D I used TArrowSeries and that worked well. Is there a 3D equivalent?
Thanks, Jim
Re: Lines between 3D points?
Posted: Mon Mar 20, 2017 10:30 am
by yeray
Hello,
You could use a second TPoint3DSeries with hidden Pointers and copy points from a series to the other.
In this example, I'm calling this second series "Links":
Code: Select all
uses TeePoin3;
var Series1, Links: TPoint3DSeries;
procedure TForm1.FormCreate(Sender: TObject);
procedure AddLink(ValueIndex1, ValueIndex2: Integer);
begin
Links.AddXYZ(Series1.XValue[ValueIndex1], Series1.YValue[ValueIndex1], Series1.ZValue[ValueIndex1]);
Links.AddXYZ(Series1.XValue[ValueIndex2], Series1.YValue[ValueIndex2], Series1.ZValue[ValueIndex2]);
Links.AddNull(0);
end;
begin
Series1:=Chart1.AddSeries(TPoint3DSeries) as TPoint3DSeries;
Series1.FillSampleValues;
Series1.LinePen.Visible:=False;
Links:=Chart1.AddSeries(TPoint3DSeries) as TPoint3DSeries;
Links.Pointer.Visible:=False;
AddLink(2,6);
AddLink(2,10);
end;
Re: Lines between 3D points?
Posted: Mon Mar 20, 2017 8:09 pm
by 16579481
So I would then have a new series for each line segment I need to draw? It would work but a generalization of TArrowSeries to 3D would be much more elegant and would make 3D just a generalization of 2D.
Re: Lines between 3D points?
Posted: Tue Mar 21, 2017 7:13 am
by yeray
Hello Jim,
If you look at the sample code I posted, you'll see I'm adding 3 points for each segment into the same series. Two of these points are the origin and destination points for the line to be drawn, and the third point is a null point, so the next time we add a line segment, we aren't connecting them.
Re: Lines between 3D points?
Posted: Tue Mar 21, 2017 7:48 am
by 16579481
Oh, I did not notice that. Not elegant but should work. Thanks.
Re: Lines between 3D points?
Posted: Wed Mar 22, 2017 7:12 pm
by 16579481
I tried that and it works except for one odd problem. If there is a line segment connecting the last point to some other point then when I rotate the chart with the mouse in some views a line suddenly appears connecting the last point to the first point. If no line connects the last point then this does not seem to happen. I know that you would like a small demo of the problem but this is all withing the large program I am working on that generates the data to be plotted.
Re: Lines between 3D points?
Posted: Thu Mar 23, 2017 6:34 pm
by 16579481
Oh, I just discovered that the 3D vector series I needed actually does exist. The TVector3DSeries series is in the VCLTee.TeeSurfa unit. Now the problem is that some lines display too light (see the screenshot). Perhaps they are drawn but much too light.
- Screen Shot 03-23-17 at 08.20 AM.PNG (24.79 KiB) Viewed 13595 times
Re: Lines between 3D points?
Posted: Fri Mar 24, 2017 8:54 am
by yeray
Hello,
JimR wrote:I tried that and it works except for one odd problem. If there is a line segment connecting the last point to some other point then when I rotate the chart with the mouse in some views a line suddenly appears connecting the last point to the first point. If no line connects the last point then this does not seem to happen. I know that you would like a small demo of the problem but this is all withing the large program I am working on that generates the data to be plotted.
I see the problem is the lines in the Point3DSeries doesn't respect the null points. I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1822
JimR wrote:Oh, I just discovered that the 3D vector series I needed actually does exist. The TVector3DSeries series is in the VCLTee.TeeSurfa unit.
Right, sorry. You can use the TVector3DSeries as follows:
Code: Select all
uses TeePoin3, TeeSurfa;
var Series1: TPoint3DSeries;
Vector: TVector3DSeries;
procedure TForm1.FormCreate(Sender: TObject);
procedure AddVector(ValueIndex1, ValueIndex2: Integer);
begin
Vector.AddVector(Series1.XValue[ValueIndex1], Series1.YValue[ValueIndex1], Series1.ZValue[ValueIndex1],
Series1.XValue[ValueIndex2], Series1.YValue[ValueIndex2], Series1.ZValue[ValueIndex2]);
end;
begin
Series1:=Chart1.AddSeries(TPoint3DSeries) as TPoint3DSeries;
Series1.FillSampleValues(5);
Series1.LinePen.Visible:=False;
Series1.Marks.Visible:=True;
Series1.Marks.Style:=smsPointIndex;
Vector:=Chart1.AddSeries(TVector3DSeries) as TVector3DSeries;
Vector.UseColorRange:=False;
Vector.Color:=clBlack;
AddVector(2,4);
AddVector(1,3);
AddVector(3, Series1.Count-1);
end;
JimR wrote:Now the problem is that some lines display too light (see the screenshot). Perhaps they are drawn but much too light.
You only have to disable UseColorRange as shown above
Re: Lines between 3D points?
Posted: Sun Mar 26, 2017 7:41 am
by 16579481
OK, this solves that problem - thanks.