Exemplo n.º 1
0
        public static TVec Normal3D(TVec p, TVec q, TVec r)
        {
            Contract.Requires(Contract.ForAll(new TVec[] { p, q, r }, x => x != null));
            Contract.Requires(Contract.ForAll(new TVec[] { p, q, r }, x => x.Dimension == 3));

            return(TVec.CrossProduct(q - p, r - p));
        }
Exemplo n.º 2
0
        public static Term Coplanarity3D(params TVec[] vecs)
        {
            Contract.Requires(Contract.ForAll(vecs, vec => vec != null));
            Contract.Requires(Contract.ForAll(vecs, vec => vec.Dimension == 3));

            var a = vecs[0];
            var b = vecs[1];
            var c = vecs[2];
            var d = vecs[3];

            var dot = TVec.CrossProduct(b - a, c - a) * (d - a); // the normal to (b-a) and (c-a) is also normal of (d-a)

            return(dot);
        }
Exemplo n.º 3
0
        private IEnumerable <TVec> GetPointsOnPlane(TVec p, TVec n)
        {
            var vec3d = random.NextVector3D().Normalized();
            var tvec  = new TVec(vec3d.X, vec3d.Y, vec3d.Z);
            var t     = TVec.CrossProduct(n, tvec);
            var u     = TVec.CrossProduct(n, t);

            yield return(p + t);

            yield return(p + u);

            yield return(p - t);

            yield return(p - u);
        }
Exemplo n.º 4
0
        private Term[] GetConcreteAnnotationTerm(CoplanarCenters coplanarCenters)
        {
            var constraints = new List <Term>();

            if (coplanarCenters.Elements.Length >= 2)
            {
                foreach (var pair in coplanarCenters.Elements.SeqPairs())
                {
                    var c1 = pair.Item1.Center;
                    var n1 = pair.Item1.Normal;
                    var c2 = pair.Item2.Center;
                    var n2 = pair.Item2.Normal;

                    var term = (c2 - c1) * TVec.CrossProduct(n1, n2);
                    constraints.Add(term);
                }
            }

            return(constraints.ToArray());
        }
Exemplo n.º 5
0
 /// <summary>
 /// Measures parallelism of two 3D vectors
 /// </summary>
 /// <param name="left">Left vector</param>
 /// <param name="right">Right vector</param>
 /// <returns></returns>
 public static Term VectorParallelism3D(TVec left, TVec right)
 {
     return(TVec.CrossProduct(left, right).NormSquared);
 }