Lines between 3D points?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Lines between 3D points?

Post by JimR » Sat Mar 18, 2017 3:10 am

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Lines between 3D points?

Post by Yeray » Mon Mar 20, 2017 10:30 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: Lines between 3D points?

Post by JimR » Mon Mar 20, 2017 8:09 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Lines between 3D points?

Post by Yeray » Tue Mar 21, 2017 7:13 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: Lines between 3D points?

Post by JimR » Tue Mar 21, 2017 7:48 am

Oh, I did not notice that. Not elegant but should work. Thanks.

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: Lines between 3D points?

Post by JimR » Wed Mar 22, 2017 7:12 pm

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.

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: Lines between 3D points?

Post by JimR » Thu Mar 23, 2017 6:34 pm

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
Screen Shot 03-23-17 at 08.20 AM.PNG (24.79 KiB) Viewed 13643 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Lines between 3D points?

Post by Yeray » Fri Mar 24, 2017 8:54 am

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 :)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: Lines between 3D points?

Post by JimR » Sun Mar 26, 2017 7:41 am

OK, this solves that problem - thanks.

Post Reply