public MultidimensionalArray ToVector()
        {
            MultidimensionalArray Vector = MultidimensionalArray.Create(1, Vertice [0].Coordinates.GetLength(1));

            Vector = SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask>
                     .ComputeVectorbetweenPoints(Vertice [0].Coordinates, Vertice [1].Coordinates);

            return(Vector);
        }
 public VerticesofCell(int CellIndex, IGridData Grid, SemiLagrangianLevelSetMethod
                       <VerticesofCell, SingleVertice, VerticeCorrectionMask> .MinimalDistanceSearchMode Correction, int FilterWidth = 10)
     : base(CellIndex, new int [1] {
     1
 })
 {
     Box = new BoundingBox(Grid.SpatialDimension);
     Grid.iGeomCells.GetCellBoundingBox(CellIndex, Box);
 }
        public double SignedDistanceToPoint(MultidimensionalArray Point)
        {
            int sign;
            MultidimensionalArray CenterToPoint = SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(Point, Center.Coordinates);

            double DotProd = SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .DotProduct(Normal, CenterToPoint);

            sign = (DotProd > 0) ? 1 : -1;
            return(sign * DistanceToPoint(Point));
        }
        public void SetNormal()
        {
            MultidimensionalArray Normal = GetNormal();

            if (SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .DotProduct(Normal, this.Normal) < 0)
            {
                Console.WriteLine("Something is wrong here: Normal Vector inverted");
            }
            this.Normal = Normal;
        }
        public MultidimensionalArray GetNormal()
        {
            MultidimensionalArray Vector = ToVector();
            MultidimensionalArray Normal = MultidimensionalArray.Create(1, Vector.GetLength(1));

            Normal [0, 0] = -Vector [0, 1];
            Normal [0, 1] = Vector [0, 0];
            Normal        = SemiLagrangianLevelSetMethod
                            <VerticesofCell, SingleVertice, VerticeCorrectionMask> .NormalizeVector(Normal);

            if (SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .DotProduct(Vertice [0].Normal, Vertice [1].Normal) < 0)
            {
                throw new Exception("Failure Normal Vector of both Points in Edge must not be ");
            }
            if (SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .DotProduct(Vertice [0].Normal, Normal) < 0)
            {
                Normal = SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .InvertVector(Normal);
            }

            return(SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .NormalizeVector(Normal));
        }
Beispiel #6
0
        public void AdjustParameters(int sign, double Radius_max, double Radius_min, MultidimensionalArray LevelSet, MultidimensionalArray LevelSetGradient)
        {
            // Set Radius
            if (sign * LevelSet[0, 0] < Radius_min)
            {
                Radius = Radius_min;
            }
            else if (sign * LevelSet[0, 0] > Radius_max)
            {
                Radius = Radius_max;
            }
            else
            {
                Radius = sign * LevelSet[0, 0];
            }

            MultidimensionalArray Normal_old = Normal.CloneAs();

            base.AdjustParameters(LevelSet, LevelSetGradient);
            int Direction = Math.Sign(SemiLagrangianLevelSetMethod
                                      <MarkersofCell, SingleLvlSetMarker, MarkerCorrectionMask> .
                                      DotProduct(Normal, Normal_old));

            if (Direction <= 0)
            {
                Active = false;
            }

            // Manage Escaped
            if (Escaped == false && -1 * sign * LevelSet[0, 0] >= Radius)
            {
                Escaped = true;
            }
            if (Escaped == true && -1 * sign * LevelSet[0, 0] < Radius)
            {
                Escaped = false;
            }
        }
        public MultidimensionalArray EdgeExtensionVector(int FrontIndex)
        {
            MultidimensionalArray OppositePoint = null;;

            for (int i = 0; i < Vertice.Length; i++)
            {
                if (i == FrontIndex)
                {
                    continue;
                }
                OppositePoint = Vertice[i].Coordinates;
            }
            if (OppositePoint == null)
            {
                throw new Exception("Failure Edge must not have more than two Vertices");
            }
            MultidimensionalArray EdgeExtension;

            EdgeExtension = SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .
                            ComputeVectorbetweenPoints(Vertice[FrontIndex].Coordinates, OppositePoint);

            return(SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .NormalizeVector(EdgeExtension));
        }
        public double DistanceToPoint(MultidimensionalArray Point)
        {
            double dist;
            double t;

            t = -(
                SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .DotProduct(
                    SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(Vertice [0].Coordinates, Point),
                    SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(Vertice [1].Coordinates, Vertice [0].Coordinates))
                ) / (
                SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .VectorNorm(
                    SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(Vertice [1].Coordinates, Vertice [0].Coordinates))
                ).Pow2();
            if (t > 1)
            {
                dist =
                    SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .VectorNorm(
                        SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(Vertice [1].Coordinates, Point));
            }
            else if (t < 0)
            {
                dist =
                    SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .VectorNorm(
                        SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(Vertice [0].Coordinates, Point));
            }
            else
            {
                dist =
                    SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .VectorNorm(
                        SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(
                            SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .VectorAddition(t,
                                                                                                                                SemiLagrangianLevelSetMethod <VerticesofCell, SingleVertice, VerticeCorrectionMask> .ComputeVectorbetweenPoints(
                                                                                                                                    Vertice [1].Coordinates, Vertice [0].Coordinates), 1, Vertice [0].Coordinates),
                            Point));
            }
            return(dist);
        }
 public double GetEdgeLength()
 {
     return(SemiLagrangianLevelSetMethod
            <VerticesofCell, SingleVertice, VerticeCorrectionMask> .VectorNorm(ToVector()));
 }