Beispiel #1
0
        public static Spectator Spectator(Point location, Vector viewDirection, Polyline headOutline = null, double majorRadius = 0.11, double minorRadius = 0.078)
        {
            if (location.IsNull() || viewDirection.IsNull())
            {
                return(null);
            }
            if (headOutline == null)
            {
                //create basic elliptical head form
                List <Point> points = new List <Point>();
                double       theta  = 2 * Math.PI / 16;
                for (int i = 0; i <= 16; i++)
                {
                    double x = minorRadius * Math.Cos(theta * i);
                    double y = majorRadius * Math.Sin(theta * i);
                    points.Add(Geometry.Create.Point(x, y, 0));
                }
                headOutline = Geometry.Create.Polyline(points);
            }

            if (!headOutline.IsPlanar() || !headOutline.IsClosed())
            {
                Reflection.Compute.RecordError("The reference headOutline must be closed and planar.");
                return(null);
            }

            //create the head
            Head head = Humans.Create.Head(location, viewDirection);

            Spectator spectator = new Spectator()
            {
                Head = head
            };

            //local cartesian
            Cartesian local = spectator.Cartesian();

            //transform the reference head outline
            TransformMatrix transform = Geometry.Create.OrientationMatrixGlobalToLocal(local);

            spectator.HeadOutline = headOutline.Transform(transform);

            return(spectator);
        }
Beispiel #2
0
        public static void HeadOutline(this Spectator spectator, Polyline newHeadOutline)
        {
            if (spectator == null || newHeadOutline.IsNull())
            {
                return;
            }

            if (!newHeadOutline.IsPlanar() || !newHeadOutline.IsClosed())
            {
                Reflection.Compute.RecordError("The reference headOutline must be closed and planar.");
                return;
            }
            //local cartesian
            Cartesian local = spectator.Cartesian();

            //transform the reference head outline
            TransformMatrix transform = Geometry.Create.OrientationMatrixGlobalToLocal(local);

            spectator.HeadOutline = newHeadOutline.Transform(transform);
        }