public static SectorOctreeGrafico Sector(OctreeGrafico OctreeGrafico, Punto3D Punto) { int Resultado = OctreeGrafico.SectorRaiz.Pertenece(ref Punto); SectorOctreeGrafico S = OctreeGrafico.SectorRaiz; if (Resultado != -2) { if (Resultado == -1) { return S; } else { while (Resultado != -2 && Resultado != -1) { Resultado = S.Pertenece(ref Punto); if (Resultado != -2) { if (Resultado == -1) { return S; } else { S = S.Hijos[Resultado]; } } else { return S.Padre; } } return S; } } else { throw new ExcepcionGeometrica3D("OctreeGrafico (PERTENECE): El punto especificado no pertenece al espacio dominado por el quadtree." + Constants.vbNewLine + "Punto=" + Punto.ToString() + Constants.vbNewLine + "Espacio=" + OctreeGrafico.Espacio.ToString()); } }
public Plano3D(Punto3D P1, Punto3D P2, Punto3D P3) { Normal = new Vector3D(P1, P2) + new Vector3D(P1, P3); mA = Normal.X; mB = Normal.Y; mC = Normal.Z; mD = -((mA * P1.X) + (mB * P1.Y) + (mC * P1.Z)); }
public Plano3D(Vector3D V1, Vector3D V2, Punto3D Punto) { Normal = V1 + V2; mA = Normal.X; mB = Normal.Y; mC = Normal.Z; mD = -((mA * Punto.X) + (mB * Punto.Y) + (mC * Punto.Z)); }
public Plano3D(Punto3D Punto, Vector3D Vector) { Normal = Vector.VectorUnitario; mA = Normal.X; mB = Normal.Y; mC = Normal.Z; mD = -((mA * Punto.X) + (mB * Punto.Y) + (mC * Punto.Z)); }
public Segmento3D(Punto3D P1, Punto3D P2) { mExtremoInicial = P1; mExtremoFinal = P2; mLongitud = Math.Sqrt((Math.Pow((P1.X + P2.X), 2)) + (Math.Pow((P1.Y + P2.Y), 2))); mRecta = new Recta3D(P1, P2); mCaja = new Caja3D(P1, new Vector3D(P2.X - P1.X, P2.Y - P1.Y, P2.Z - P1.Z)); }
public Foco3D(Punto3D Posicion, Color Color) { if (Color != System.Drawing.Color.Black && Color.A == 255) { mCoordenadasSUR = Posicion; mColor = Color; mIntensidad = 1; } else { throw new ExcepcionEscena("FOCO3D (COLOR_SET): No se puede asignar un color negro o semitransparente." + Constants.vbNewLine + "Color=ARGB(" + Color.A + "," + Color.R + "," + Color.G + "," + Color.B + ")"); } }
public static double Distancia(Recta3D Recta, Punto3D Punto) { return (new Vector3D(Recta.ObtenerPuntoParametrico(0), Punto) + Recta.VectorDirector).Modulo; }
public bool Pertenece(Punto3D Punto) { return PlanoA.Pertenece(Punto) && PlanoB.Pertenece(Punto); }
public static double SignoPosicionRelativa(Plano3D Plano, Punto3D Punto) { return Math.Sign((Plano.A * Punto.X) + (Plano.B * Punto.Y) + (Plano.C * Punto.Z) + Plano.D); }
public void RecalcularCentro() { mCentroSUR = Vertice.BaricentroSUR(mVertices); }
public int Pertenece(ref Punto3D Punto) { return Pertenece(ref this, Punto); }
public static Matriz RepresentacionMatricial(Punto3D Punto) { return Punto.Matriz; }
public static Punto3D Incremento(Punto3D Punto, double IncrementoX, double IncrementoY, double IncrementoZ) { return new Punto3D(Punto.X + IncrementoX, Punto.Y + IncrementoY, Punto.Z + IncrementoZ); }
public static Punto3D Proyeccion(Punto3D Punto, Recta3D Recta) { int Landa = 0; double Vx = 0; double Vy = 0; double Vz = 0; double VVx = 0; double VVy = 0; double VVz = 0; double Qx = 0; double Qy = 0; double Qz = 0; double x = 0; double y = 0; double z = 0; Vx = Recta.VectorDirector.X; Vy = Recta.VectorDirector.Y; Vz = Recta.VectorDirector.Z; VVx = Vx * Vx; VVy = Vy * Vy; VVz = Vz * Vz; Qx = Recta.PuntoInicial.X; Qy = Recta.PuntoInicial.Y; Qz = Recta.PuntoInicial.Z; x = Punto.X; y = Punto.Y; z = Punto.Z; Landa = ((Vx * (x - Qx)) + (Vy * (y - Qy)) + (Vz * (z - Qz))) / (VVx + VVy + VVz); return Recta.ObtenerPuntoParametrico(Landa); }
public static Punto2D Proyectar(Proyeccion Proyeccion, Punto3D Punto) { return new Punto2D(Proyeccion.Matriz * Punto.Matriz); }
public double SignoPosicionRelativa(Punto3D Punto) { return Math.Sign((mA * Punto.X) + (mB * Punto.Y) + (mC * Punto.Z) + mD); }
public double PosicionRelativa(Punto3D Punto) { return (mA * Punto.X) + (mB * Punto.Y) + (mC * Punto.Z) + mD; }
public bool Pertenece(Punto3D Punto) { return ((mA * Punto.X) + (mB * Punto.Y) + (mC * Punto.Z) + mD == 0); }
public SectorOctree Sector(Punto3D Punto) { return Sector(this, Punto); }
public bool Pertenece(Punto3D Punto) { return Pertenece(this, Punto); }
public PosicionRelativa3D(Punto3D ValInterseccion) { mTipo = TipoPosicionRelativa3D.Secante; mInterseccion = ValInterseccion; }
public bool Pertenece(Segmento3D Segmento, Punto3D Punto) { return mCaja.Pertenece(Punto) && mRecta.Pertenece(Punto); }
public static Punto3D Incremento(Punto3D P1, Punto3D P2) { return new Punto3D(P1.X + P2.X, P1.Y + P2.Y, P1.Z + P2.Z); }
public Recta3D(Plano3D P1, Plano3D P2) { PlanoA = P1; PlanoB = P2; mVector = (P1.VectorNormal + P2.VectorNormal).VectorUnitario; mPunto = ObtenerPuntoParametrico(0); mPuntoMira = ObtenerPuntoParametrico(10); }
public static Punto3D Copia(Punto3D Punto) { return new Punto3D(Punto.X, Punto.Y, Punto.Z); }
public Recta3D(Punto3D P1, Punto3D P2) : this(P1, new Vector3D(P1, P2)) { }
public static int Pertenece(ref SectorOctree Sector, ref Punto3D Punto) { if (!Sector.EsHoja) { for (int i = 0; i <= 7; i++) { if (Sector.Hijos[i].Espacio.Pertenece(Punto)) { return i; } } } else { if (Sector.Espacio.Pertenece(Punto)) { return -1; } else { return -2; } } }
public Recta3D(params Matriz[] Matrices) { if (Matrices.GetUpperBound(0) == 1) { Punto3D Punto = new Punto3D(Matrices[0]); Punto3D Punto2 = new Punto3D(Matrices[1]); mPunto = Punto; mPuntoMira = Punto2; mVector = new Vector3D(mPunto, mPuntoMira).VectorUnitario; //ÉSTOS VALORES SE OBTIENEN AL DESPEJAR LA ECUACIÓN PARAMÉTRICA DE UNA RECTA GENÉRICA: PlanoA = new Plano3D(mVector.Y, -mVector.X, 0, (-mVector.Y * Punto.X) + (mVector.X * Punto.Y)); PlanoB = new Plano3D(0, mVector.Z, -mVector.Y, (-mVector.Z * Punto.Y) + (mVector.Y * Punto.Z)); } else { throw new ExcepcionGeometrica3D("RECTA3D (NEW): La representación matricial de una recta corresponde a un array con dos matrices" + Constants.vbNewLine + "Tamaño del array=" + Matrices.GetUpperBound(0) + 1); } }
public void RecalcularRepresentaciones(Camara3D Camara) { for (int i = 0; i <= mVertices.GetUpperBound(0); i++) { mVertices[i].CoodenadasSRC = Camara.TransformacionSURtoSRC * mVertices[i].CoodenadasSUR; mVertices[i].Representacion = Camara.Proyeccion(mVertices[i].CoodenadasSRC, true); } if (NormalesCentro) { for (int i = 0; i <= mCaras.GetUpperBound(0); i++) { mCaras[i].RecalcularBaricentroSRC(mVertices); mCaras[i].NormalSRC = new Vector3D(mCentroSRC, mCaras[i].BaricentroSRC).VectorUnitario; } } else { for (int i = 0; i <= mCaras.GetUpperBound(0); i++) { mCaras[i].RecalcularBaricentroSRC(mVertices); mCaras[i].NormalSRC = Cara.VectorNormalSRC(mCaras[i], mVertices); } } mCentroSRC = Camara.TransformacionSURtoSRC * mCentroSUR; if (mAutoRecalcularCajas) mCajaSRC = ObtenerCajaSRC(); }
public Recta3D(Punto3D Punto, Vector3D Vector) { mPunto = Punto; mPuntoMira = new Punto3D(mPunto.X + Vector.X, mPunto.Y + Vector.Y, mPunto.Z + Vector.Z); mVector = Vector.VectorUnitario; //ÉSTOS VALORES SE OBTIENEN AL DESPEJAR LA ECUACIÓN PARAMÉTRICA DE UNA RECTA GENÉRICA: PlanoA = new Plano3D(Vector.Y, -Vector.X, 0, (-Vector.Y * Punto.X) + (Vector.X * Punto.Y)); PlanoB = new Plano3D(0, Vector.Z, -Vector.Y, (-Vector.Z * Punto.Y) + (Vector.Y * Punto.Z)); }