Beispiel #1
0
 public override void GetBoundingBox(ref double xmin,
                                     ref double xmax,
                                     ref double ymin,
                                     ref double ymax,
                                     ref double zmin,
                                     ref double zmax,
                                     ChMatrix33 <double> Rot)
 {
     if (Rot == null)
     {
         xmin = ChMaths.ChMin(ChMaths.ChMin(p1.x, p2.x), p3.x);
         ymin = ChMaths.ChMin(ChMaths.ChMin(p1.y, p2.y), p3.y);
         zmin = ChMaths.ChMin(ChMaths.ChMin(p1.z, p2.z), p3.z);
         xmax = ChMaths.ChMax(ChMaths.ChMax(p1.x, p2.x), p3.x);
         ymax = ChMaths.ChMax(ChMaths.ChMax(p1.y, p2.y), p3.y);
         zmax = ChMaths.ChMax(ChMaths.ChMax(p1.z, p2.z), p3.z);
     }
     else
     {
         ChVector trp1 = Rot.MatrT_x_Vect(p1);
         ChVector trp2 = Rot.MatrT_x_Vect(p2);
         ChVector trp3 = Rot.MatrT_x_Vect(p3);
         xmin = ChMaths.ChMin(ChMaths.ChMin(trp1.x, trp2.x), trp3.x);
         ymin = ChMaths.ChMin(ChMaths.ChMin(trp1.y, trp2.y), trp3.y);
         zmin = ChMaths.ChMin(ChMaths.ChMin(trp1.z, trp2.z), trp3.z);
         xmax = ChMaths.ChMax(ChMaths.ChMax(trp1.x, trp2.x), trp3.x);
         ymax = ChMaths.ChMax(ChMaths.ChMax(trp1.y, trp2.y), trp3.y);
         zmax = ChMaths.ChMax(ChMaths.ChMax(trp1.z, trp2.z), trp3.z);
     }
 }
Beispiel #2
0
            /// Add a cylinder to this model (default axis on Y direction), for collision purposes
            public override bool AddCylinder(double rx,
                                             double rz,
                                             double hy,
                                             ChVector pos,
                                             ChMatrix33 <double> rot)
            {
                // adjust default inward margin (if object too thin)
                this.SetSafeMargin(ChMaths.ChMin(this.GetSafeMargin(), 0.2 * ChMaths.ChMin(ChMaths.ChMin(rx, rz), 0.5 * hy)));

                float         arx    = (float)(rx + this.GetEnvelope());
                float         arz    = (float)(rz + this.GetEnvelope());
                float         ahy    = (float)(hy + this.GetEnvelope());
                CylinderShape mshape = new CylinderShape(new IndexedVector3(arx, ahy, arz));

                mshape.SetMargin(this.GetSuggestedFullMargin());

                _injectShape(pos, rot, mshape);

                return(true);
            }
Beispiel #3
0
            /// Add a box shape to this model, for collision purposes
            public override bool AddBox(
                double hx,              /// the halfsize on x axis
                double hy,              /// the halfsize on y axis
                double hz,              /// the halfsize on z axis
                ChVector pos,           /// the position of the box COG
                ChMatrix33 <double> rot /// the rotation of the box - matrix must be orthogonal
                )
            {
                // adjust default inward margin (if object too thin)
                this.SetSafeMargin(ChMaths.ChMin(this.GetSafeMargin(), 0.2 * ChMaths.ChMin(ChMaths.ChMin(hx, hy), hz)));

                float    ahx    = (float)(hx + this.GetEnvelope());
                float    ahy    = (float)(hy + this.GetEnvelope());
                float    ahz    = (float)(hz + this.GetEnvelope());
                BoxShape mshape = new BoxShape(new IndexedVector3(ahx, ahy, ahz));

                mshape.SetMargin((float)this.GetSuggestedFullMargin());

                _injectShape(pos, rot, mshape);

                return(true);
            }