Example #1
0
 public Edge(PlanePoint p1, PlanePoint p2)
 {
     if (p1.Dim != p2.Dim)
     {
         throw new ArgumentException("_points have different dimensions.");
     }
     if (p1 == p2)
     {
         throw new ArgumentException("Objects are equal.");
     }
     _points       = new[] { p1, p2 };
     AdjacentCells = new List <ICell>();
     Hyperplane    = Hyperplane.Create(_points);
 }
Example #2
0
        public static Hyperplane Create(IList <PlanePoint> points)
        {
            if (!points.HaveSameDimension())
            {
                throw new ArgumentException("Basis don't have same dimension");
            }
            if (points.Count != points[0].Dim)
            {
                throw new ArgumentException("Number of points is not equal to dimension.");
            }
            Vector[]   vectors    = points.ToVectors();
            Hyperplane hyperplane = Create(points.First(), vectors);


            return(hyperplane);
        }
Example #3
0
        public bool Equals(Hyperplane other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (Dimension != other.Dimension)
            {
                return(false);
            }
            List <double> quotients = new List <double>();

            for (int i = 0; i < other.Dimension; i++)
            {
                if (Tools.NE(Normal[i]))
                {
                    quotients.Add(other.Normal[i] / Normal[i]);
                }
                else
                {
                    if (Tools.NE(other.Normal[i]))
                    {
                        return(false);
                    }
                }
            }

            if (Tools.NE(NumericVariable) && Tools.NE(other.NumericVariable))
            {
                quotients.Add(other.NumericVariable / NumericVariable);
            }

            return(quotients.Count == 0 || quotients.All(d => Tools.EQ(d, quotients[0])));
        }
Example #4
0
 public Face(Hyperplane hyperplane)
 {
     Hyperplane    = hyperplane ?? throw new ArgumentNullException(nameof(hyperplane));
     Dimension     = hyperplane.Dimension;
     AdjacentCells = new List <ICell>();
 }
Example #5
0
 public double Cos(Hyperplane hyperplane)
 {
     return(Normal * hyperplane.Normal);//Normal.Length = 1
 }
Example #6
0
 public double Angle(Hyperplane hyperplane)
 {
     return(Vector.Angle(Normal, hyperplane.Normal));
 }
Example #7
0
 public Hyperplane(Hyperplane h) : this(h.MainPoint, h.Normal)
 {
     Basis = h.Basis;
 }