@@ -646,11 +646,13 @@ namespace lib {
646646 // create all 8 homogenous coordinates of the cubes points,
647647 // compute their projected coord,
648648 // find min and max on both axes.
649- static DDoubleGDL* cube_coord = (new DDoubleGDL (dimension (8 ,4 ), BaseGDL::NOZERO));
650- static DDouble vals[32 ]={0 ,1 ,0 ,1 ,0 ,1 ,0 ,1 ,0 ,0 ,1 ,1 ,0 ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 };
651- for (auto i=0 ; i< 32 ; ++i) (*cube_coord)[i]=vals[i];
649+ static DDouble vals[32 ] = {0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 1 , 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 };
650+ // static DDoubleGDL cube_coord(dimension(8,4), BaseGDL::NOZERO);
651+ static DDoubleGDL cube_coord (vals,32 );
652+ cube_coord.SetDim (dimension (8 ,4 )); // needed as previous initializaton is 1D only.
653+ // for (auto i=0; i< 32; ++i) (*(&cube_coord))[i]=vals[i];
652654 // w=v#!p.t
653- DDoubleGDL* tmp = plplot3d->MatrixOp (cube_coord, false , true );
655+ DDoubleGDL* tmp = plplot3d->MatrixOp (& cube_coord, false , true );
654656 DDoubleGDL* res = static_cast <DDoubleGDL*>(tmp->Transpose (NULL ));
655657 GDLDelete (tmp);
656658// SelfPrint3d(res);
@@ -718,6 +720,22 @@ DDoubleGDL* gdlDoAsScale3(DDouble az, DDouble alt, DDouble *scalex, DDouble *sca
718720 return t3dMatrix;
719721 }
720722
723+ // this displaces 3d elements made in NoSubpage mode to a particular subpage. Used for axis for example.
724+ void gdlMakeSubpageRotationMatrix3d (DDoubleGDL* me, PLFLT xratio, PLFLT yratio, PLFLT zratio, PLFLT* trans) {
725+ DDouble newscale[3 ]={ xratio, yratio, zratio};
726+ SelfTranspose3d (me);
727+ SelfScale3d (me,newscale);
728+ SelfTranslate3d (me,trans);
729+ SelfTranspose3d (me);
730+ }
731+ // this displaces 2D elements (images, already reprojected 3d) made in NoSubpage mode to a particluar subpage
732+ void gdlMakeSubpageRotationMatrix2d (DDoubleGDL* me, PLFLT xratio, PLFLT yratio, PLFLT zratio, PLFLT* trans) {
733+ DDouble newscale[3 ]={ xratio, yratio, zratio};
734+ SelfReset3d (me);
735+ SelfScale3d (me,newscale);
736+ SelfTranslate3d (me,trans);
737+ SelfTranspose3d (me);
738+ }
721739 // converts 3D values according to COORDSYS towards NORMAL coordinates and , logically, unset xLog,yLo,zLog and define code as NORMAL.
722740 void SelfConvertToNormXYZ (DDoubleGDL *x, bool &xLog, DDoubleGDL *y, bool &yLog, DDoubleGDL *z, bool &zLog, COORDSYS &code) {
723741// std::cerr<<"SelfConvertToNormXYZ(DDoubleGDL)\n";
@@ -981,7 +999,7 @@ bool isAxonometricRotation(DDoubleGDL* Matrix, DDouble &alt, DDouble &az, DDoubl
981999 // Note that if drawing of axes and hidden surfaces (by plplot) are not needed (e.g., PLOTS), any matrix can be used.
9821000 // Returns a 'plplot-compatible' matrix that will be used in calls to plplot.
9831001 // Retunrs NULL if conversion is impossible.
984- bool gdlInterpretT3DMatrixAsPlplotRotationMatrix (DDouble &az, DDouble &alt, DDouble &ay, DDouble *scale, T3DEXCHANGECODE &axisExchangeCode, bool &below) {
1002+ bool gdlInterpretT3DMatrixAsPlplotRotationMatrix (DDouble &az, DDouble &alt, DDouble &ay, DDouble *scale, /* DDouble *trans, */ T3DEXCHANGECODE &axisExchangeCode, bool &below) {
9851003// std::cerr<<"gdlInterpretT3DMatrixAsPlplotRotationMatrix(()\n";
9861004 // returns NULL if error!
9871005 DDoubleGDL* t3dMatrix = new DDoubleGDL (dimension (4 , 4 ),BaseGDL::NOZERO);
@@ -991,6 +1009,12 @@ bool isAxonometricRotation(DDoubleGDL* Matrix, DDouble &alt, DDouble &az, DDoubl
9911009 static unsigned tTag = pStruct->Desc ()->TagIndex (" T" );
9921010 for (int i = 0 ; i < t3dMatrix->N_Elements (); ++i)(*t3dMatrix)[i] = (*static_cast <DDoubleGDL*> (pStruct->GetTag (tTag, 0 )))[i];
9931011 SelfTranspose3d (t3dMatrix);
1012+ // //compute translation in vport space using the displacement of [0,0,0]:
1013+ // static DDouble center[4]={0.5,0.5,0.5,1.};
1014+ // static DDoubleGDL zeropos(center,4);
1015+ // DDoubleGDL* intermediary = t3dMatrix->MatrixOp(&zeropos, false, false);
1016+ // for (int i=0; i< 3; ++i) trans[i]= (*intermediary)[i]-0.5;
1017+ // GDLDelete(intermediary);
9941018 // check if valid, get rotation etc.
9951019 if (!isAxonometricRotation (t3dMatrix, alt, az, ay, scale, axisExchangeCode, below)) return false ;
9961020 return true ;
0 commit comments