Drawing in 3D Space Derived Classes


I am attempting to create a derived class from TEllipse that will allow me to draw ellipses embedded in 3D space. I am unsure about the best way to accomplish this. I am assuming I need to define a paint method in my derived class. However,I am not 100% clear what the best approach is for the paint method. I have looked at paint for TEllipse, which makes calls to TPad methods. I also looked at the TPolyLine3D class. Could you give me some guidance on the best way to accomplish what I want.



It all depends what you want to do. What do you mean by an ellipse in 3d ? a 2D ellipse in a plane or a 3d ellipsoid ?

I want to draw a series of 2D ellipses in a plane at various points in 3d space (not an ellipsoid). Thanks


May you can get inspiration from the following macro. You will have to use TPolyLine3D to build your ellipses.

   c1 = new TCanvas("c1","PolyLine3D & PolyMarker3D Window",200,10,500,500);

   // Creating a view
   TView3D *view = TView::CreateView(1);

   // Create a first PolyLine3D
   TPolyLine3D *pl3d1 = new TPolyLine3D(5);
   pl3d1->SetPoint(0, 10, 10, 10);
   pl3d1->SetPoint(1, 15, 15, 10);
   pl3d1->SetPoint(2, 20, 15, 15);
   pl3d1->SetPoint(3, 20, 20, 20);
   pl3d1->SetPoint(4, 10, 10, 20);

   // Create a first PolyMarker3D
   TPolyMarker3D *pm3d1 = new TPolyMarker3D(12);
   pm3d1->SetPoint(0, 10, 10, 10);
   pm3d1->SetPoint(1, 11, 15, 11);
   pm3d1->SetPoint(2, 12, 15, 9);
   pm3d1->SetPoint(3, 13, 17, 20);
   pm3d1->SetPoint(4, 14, 16, 15);
   pm3d1->SetPoint(5, 15, 20, 15);
   pm3d1->SetPoint(6, 16, 18, 10);
   pm3d1->SetPoint(7, 17, 15, 10);
   pm3d1->SetPoint(8, 18, 22, 15);
   pm3d1->SetPoint(9, 19, 28, 25);
   pm3d1->SetPoint(10, 20, 12, 15);
   pm3d1->SetPoint(11, 21, 12, 15);

   // Draw

Yes. I was considering this type of thing. I am assuming I should place this in a paint virtual method for my derived class? Or should I make direct calls to tpad::polyline3d method, which I see in a lot of the root code. Which approach is better and why?

I think the best would be to make a TEllipse3D class based on the TPolyLine3D model.


Ok. I have the 3D Ellipses drawing correctly as per the screenshot I attach. I derived a class from TEllipse instead of deriving from TPolyLine3D. Do you see an issue with that?

However, the main issue now is how do I fill these ellipses? They are TPolyLine3D objects. Is there a way to fill those?


Ellipses.pdf (70.7 KB)

You should also derive from TAttFill
You will need to draw filles polygons, note lines.