Ejemplo n.º 1
0
        public static double[] ReflectNormal(double[] normal, MyPlane candidateReflMyPlane)
        {
            double[] planeNormal = { candidateReflMyPlane.a, candidateReflMyPlane.b, candidateReflMyPlane.c };
            double[] origin      = { 0, 0, 0 };
            var      planeForReflectionOfNormals = new MyPlane(planeNormal, origin);
            var      normalMyVertex          = new MyVertex(normal[0], normal[1], normal[2]);
            var      reflectedNormalMyVertex = normalMyVertex.Reflect(planeForReflectionOfNormals);

            double[] reflectedNormal = { reflectedNormalMyVertex.x, reflectedNormalMyVertex.y, reflectedNormalMyVertex.z };
            return(reflectedNormal);
        }
Ejemplo n.º 2
0
        public static bool CylinderOfFirstAtPosition_i_IsOkReflection(MyRepeatedEntity firstMyRepeatedEntity,
                                                                      MyRepeatedEntity secondMyRepeatedEntity, MyPlane candidateReflMyPlane, MyCylinder cylinderOfFirst, ref int i)
        {
            const string nameFile  = "GetReflectionalPattern.txt";
            var          tolerance = Math.Pow(10, -5);

            //I compute the distance vector v between the centroidOfFirst and the Origin of the cylinderOfFirst (which pass through the axis)
            //The axis of the second MyRepeatedEntity should have the same axis direction and
            //should pass through the point = centroidOfSecond + v
            double[] originOfFirst         = cylinderOfFirst.originCylinder;
            var      originOfFirstMyVertex = new MyVertex(originOfFirst[0], originOfFirst[1], originOfFirst[2]);

            var pointOnAxisMyVertex = originOfFirstMyVertex.Reflect(candidateReflMyPlane);

            double[] pointOnAxis = { pointOnAxisMyVertex.x, pointOnAxisMyVertex.y, pointOnAxisMyVertex.z };

            var reflectedDirectionOfAxis = ReflectNormal(cylinderOfFirst.axisDirectionCylinder, candidateReflMyPlane);

            var axisToFind = FunctionsLC.ConvertPointPlusDirectionInMyLine(pointOnAxis,
                                                                           reflectedDirectionOfAxis);
            var indOfFound =
                secondMyRepeatedEntity.listOfCylindricalSurfaces.FindIndex(
                    cyl => cyl.axisCylinder.Equals(axisToFind));

            if (indOfFound != -1)
            {
                var listOfPossibleCylinders =
                    secondMyRepeatedEntity.listOfCylindricalSurfaces.FindAll(
                        cyl => cyl.axisCylinder.Equals(axisToFind));
                var numOfPossibleCylinders = listOfPossibleCylinders.Count;

                //If I find cylinders with right axis line, I check the radius correspondence,
                //the center of bases correspondence.
                //For elliptical bases I make a further control on radius and direction axis.
                var notFound = true;
                int j        = 0;
                while (notFound && j < numOfPossibleCylinders)
                {
                    var possibleCylinder = listOfPossibleCylinders[j];
                    if (Math.Abs(cylinderOfFirst.radiusCylinder - possibleCylinder.radiusCylinder) < tolerance)
                    {
                        if (CheckOfClosedEdgesCorrespondenceRefl(cylinderOfFirst, possibleCylinder,
                                                                 candidateReflMyPlane))
                        {
                            notFound = false;
                        }
                    }
                    j++;
                }
                if (notFound)
                {
                    return(false);
                }

                //if the previous cylinder is ok, i pass to the next cylinder:
                i++;
            }
            else
            {
                return(false);
            }
            return(true);
        }