protected bool Equals(MyVertex other) { var toll = Math.Pow(10, -4); return(Math.Abs(x - other.x) < toll && Math.Abs(y - other.y) <= toll && Math.Abs(z - other.z) <= toll); //return x.Equals(other.x) && y.Equals(other.y) && z.Equals(other.z); }
public MyCircumForPath(MyPlane CircumPlane, MySphere circumMySphere) { this.circumplane = CircumPlane; this.circumsphere = circumMySphere; //computation of the circle center: double[] centerSphereVector = { this.circumsphere.centerSphere[0], this.circumsphere.centerSphere[1], this.circumsphere.centerSphere[2] }; var centerSphereOfCircumMyVertex = new MyVertex(centerSphereVector[0], centerSphereVector[1], centerSphereVector[2]); double[] planeNormal = { this.circumplane.a, this.circumplane.b, this.circumplane.c }; var pointOnAxisMyVertex = new MyVertex(centerSphereOfCircumMyVertex.x + planeNormal[0], centerSphereOfCircumMyVertex.y + planeNormal[1], centerSphereOfCircumMyVertex.z + planeNormal[2]); var rotationAxis = FunctionsLC.LinePassingThrough(centerSphereOfCircumMyVertex, pointOnAxisMyVertex); this.circumcenter = FunctionsLC.PointIntersectionOfPlaneAndLine(this.circumplane, rotationAxis); }
//Applied to a firstvertex, given secondvertex and a double[3], it verifies if firstvertex is obtained summing secondvertex with double[3] public bool IsTranslationOf(MyVertex secondVertex, double[] translationArray) { var translatedVertex = new MyVertex(secondVertex.x + (double)translationArray.GetValue(0), secondVertex.y + (double)translationArray.GetValue(1), secondVertex.z + (double)translationArray.GetValue(2)); return(this.Equals(translatedVertex)); }
//Applied to a firstvertex, given secondvertex, an angle and a axis direction, it verifies if secondvertex //is the rotated of firstvertex public bool IsRotationOf(MyVertex firstVertex, double teta, double[] axisDirection) { //const string nameFile = "GetRotationalPatterns.txt"; var rotatedVertex = firstVertex.Rotate(teta, axisDirection); //KLdebug.Print("ROTATO DOVREBBE ESSERE: (" + rotatedVertex.x + ", " + rotatedVertex.y + ", " +rotatedVertex.z + ")", nameFile); return(this.Equals(rotatedVertex)); }
//Applied to a MyVertex, this method reflects it by a given MyPlane //RECALL: // P: x*u = lambda , x in R^3, u in R^3 unit vector <-- Reflectional Plane // R_P(x) = x-2(x*u-lambda)u <-- Reflectional transformation public MyVertex Reflect(MyPlane reflectionalMyPlane) { double[] coeff = { 2 * (this.x * reflectionalMyPlane.a + reflectionalMyPlane.d), 2 * (this.y * reflectionalMyPlane.b + reflectionalMyPlane.d), 2 * (this.z * reflectionalMyPlane.c + reflectionalMyPlane.d) }; var reflectedVertex = new MyVertex(this.x - (double)coeff.GetValue(0) * reflectionalMyPlane.a, this.y - (double)coeff.GetValue(1) * reflectionalMyPlane.b, this.z - (double)coeff.GetValue(2) * reflectionalMyPlane.c); return(reflectedVertex); }
public MyEllipse(double[] EllipseParameters) //Curve myEllipse { //double[] ellipseParam = myEllipse.GetEllipseParams(); this.centerEllipse = new MyVertex(EllipseParameters[0], EllipseParameters[1], EllipseParameters[2]); this.majorRadEllipse = EllipseParameters[3]; double[] vectorMajorAxisDirectionEllipse = { EllipseParameters[4], EllipseParameters[5], EllipseParameters[6] }; this.majorAxisDirectionEllipse = vectorMajorAxisDirectionEllipse; //this.majorAxisRadEllipse = FunctionsLC.ConvertPointPlusDirectionInMyLine(centerEllipseArray, //majorRadVectorEllipse); this.minorRadEllipse = EllipseParameters[7]; double[] vectorMinorAxisDirectionEllipse = { EllipseParameters[8], EllipseParameters[9], EllipseParameters[10] }; this.minorAxisDirectionEllipse = vectorMinorAxisDirectionEllipse; //this.minorAxisRadEllipse = FunctionsLC.ConvertPointPlusDirectionInMyLine(centerEllipseArray, //minorAxisRadVectorEllipse); }
public MyRepeatedEntity(int IdRE, MyVertex Centroid, List <MyVertex> ListOfVertices, List <MyVertex> ListOfAddedVertices, List <MyPlane> ListOfPlanarSurfaces, List <MySphere> ListOfSphericalSurfaces, List <MyCone> ListOfConicalSurfaces, List <MyCylinder> ListOfCylindricalSurfaces, List <MyTorus> ListOfToroidalSurfaces, double[,] TransformationMatrix) { this.idRE = IdRE; this.centroid = Centroid; this.listOfVertices = ListOfVertices; this.listOfAddedVertices = ListOfAddedVertices; this.listOfPlanarSurfaces = ListOfPlanarSurfaces; this.listOfSphericalSurfaces = ListOfSphericalSurfaces; this.listOfConicalSurfaces = ListOfConicalSurfaces; this.listOfCylindricalSurfaces = ListOfCylindricalSurfaces; this.listOfToroidalSurfaces = ListOfToroidalSurfaces; this.transformationMatrix = TransformationMatrix; }
public MyRepeatedComponent(Component2 component, int idCorrespondingNode, MyTransformMatrix transform, bool isLeaf, MyRepeatedEntity repeatedEntity) { this.Component = component; Name = component.Name2; IdCorrespondingNode = idCorrespondingNode; this.Transform = transform; this.IsLeaf = isLeaf; var originVertex = new MyVertex(transform.TranslationVector[0], transform.TranslationVector[1], transform.TranslationVector[2]); this.Origin = originVertex; RepeatedEntity = repeatedEntity; IsSphere = false; }
//Applicato ad un vertice, restituisce la sua distanza euclidea da un altro vertice public double Distance(MyVertex other) { if (this.Equals(other)) { return(0); } else { var distance = Math.Sqrt(Math.Pow(this.x - other.x, 2) + Math.Pow(this.y - other.y, 2) + Math.Pow(this.z - other.z, 2)); if (!Double.IsNaN(distance)) { return(distance); } return(-1); } }
//Applied to a MyVertex, this method rotates it by a given angle TETA respect to a given //NORMAL DIRECTION VECTOR referred to a rotation axis passing through the origin public MyVertex Rotate(double teta, double[] axisDirection) { double[] pointToRotate = { this.x, this.y, this.z }; //double[] row0 = //{ // Math.Pow(axisDirection[0], 2)*(1 - Math.Cos(teta)) + Math.Cos(teta), // axisDirection[0]*axisDirection[1]*(1 - Math.Cos(teta)) - axisDirection[2]*Math.Sin(teta), // axisDirection[0]*axisDirection[2]*(1 - Math.Cos(teta)) + axisDirection[1]*Math.Sin(teta) //}; //double[] row1 = //{ // axisDirection[0]*axisDirection[1]*(1 - Math.Cos(teta)) + axisDirection[2]*Math.Sin(teta), // Math.Pow(axisDirection[1], 2)*(1 - Math.Cos(teta)) + Math.Cos(teta), // axisDirection[1]*axisDirection[2]*(1 - Math.Cos(teta)) - axisDirection[0]*Math.Sin(teta) //}; //double[] row2 = //{ // axisDirection[0]*axisDirection[2]*(1 - Math.Cos(teta)) - axisDirection[1]*Math.Sin(teta), // axisDirection[1]*axisDirection[2]*(1 - Math.Cos(teta)) + axisDirection[0]*Math.Sin(teta), // Math.Pow(axisDirection[2], 2)*(1 - Math.Cos(teta)) + Math.Cos(teta) //}; double[,] rotationMatrix = { { Math.Pow(axisDirection[0], 2) * (1 - Math.Cos(teta)) + Math.Cos(teta), axisDirection[0] * axisDirection[1] * (1 - Math.Cos(teta)) - axisDirection[2] * Math.Sin(teta), axisDirection[0] * axisDirection[2] * (1 - Math.Cos(teta)) + axisDirection[1] * Math.Sin(teta) }, { axisDirection[0] * axisDirection[1] * (1 - Math.Cos(teta)) + axisDirection[2] * Math.Sin(teta), Math.Pow(axisDirection[1], 2) * (1 - Math.Cos(teta)) + Math.Cos(teta), axisDirection[1] * axisDirection[2] * (1 - Math.Cos(teta)) - axisDirection[0] * Math.Sin(teta) }, { axisDirection[0] * axisDirection[2] * (1 - Math.Cos(teta)) - axisDirection[1] * Math.Sin(teta), axisDirection[1] * axisDirection[2] * (1 - Math.Cos(teta)) + axisDirection[0] * Math.Sin(teta), Math.Pow(axisDirection[2], 2) * (1 - Math.Cos(teta)) + Math.Cos(teta) } }; var rotated = Matrix.Multiply(rotationMatrix, pointToRotate); var rotatedVertex = new MyVertex(rotated[0], rotated[1], rotated[2]); return(rotatedVertex); }
public MyRepeatedComponent(Component2 component, MyTransformMatrix transform, bool isLeaf, MyRepeatedEntity repeatedEntity) { this.Component = component; var pathComponent = component.Name2; var componentName = pathComponent.Split('/').Last(); Name = componentName; this.Transform = transform; this.IsLeaf = isLeaf; var originVertex = new MyVertex(transform.TranslationVector[0], transform.TranslationVector[1], transform.TranslationVector[2]); this.Origin = originVertex; RepeatedEntity = repeatedEntity; IsSphere = false; }
//Applied to a firstvertex, given secondvertex and a MyPlane, it verifies if secondvertex is the reflected of //firstvertex by the given MyPlane public bool IsReflectionOf(MyVertex secondVertex, MyPlane reflectionalMyPlane) { var reflectedVertex = this.Reflect(reflectionalMyPlane); return(secondVertex.Equals(reflectedVertex)); }