Exemple #1
0
    // window
    public MainWindow() : base(WindowType.Toplevel)
    {
        Build();
        isInitialized = false;
        random        = new Random();
        // visual
        surface           = new ImageSurface(Format.RGB24, 2000, 2000);
        root.ExposeEvent += (sender, e) => {
            Context gc = Gdk.CairoHelper.Create(root.GdkWindow);
            gc.SetSourceSurface(surface, 0, 0);
            gc.Paint();
            gc.Dispose();
        };
        root.AddEvents((int)Gdk.EventMask.ButtonPressMask);

        // geometry
        double       dx        = Math.Sin(INIT_ROT) * Math.Sin(Y_ANG);
        double       dy        = Math.Cos(Y_ANG);
        double       dz        = Math.Cos(INIT_ROT) * Math.Sin(Y_ANG);
        UnitVector3D norm      = new UnitVector3D(dx, dy, dz);
        Point3D      rootPoint = norm.ScaleBy(INIT_DIST).ToPoint3D();

        proj  = new Plane(rootPoint, norm);
        yAxis = proj.Project(new UnitVector3D(0, 1, 0)).Direction;
        xAxis = yAxis.CrossProduct(norm);
    }
Exemple #2
0
    protected void HScaleDistance(object sender, EventArgs e)
    {
        UnitVector3D norm      = proj.Normal;
        Point3D      rootPoint = norm.ScaleBy(hscaleDist.Value).ToPoint3D();

        proj = new Plane(rootPoint, norm);
        RenderRoot();
    }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CoordinateSystemVelocity3D"/> struct.
 /// </summary>
 /// <param name="originCoordinateSystem">The origin coordinate system.</param>
 /// <param name="angularAxis">The axis of angular velocity.</param>
 /// <param name="angularSpeed">The angular speed around the axis.</param>
 /// <param name="linearDirection">The direction of linear velocity.</param>
 /// <param name="linearSpeed">The linear speed.</param>
 public CoordinateSystemVelocity3D(
     CoordinateSystem originCoordinateSystem,
     UnitVector3D angularAxis,
     double angularSpeed,
     UnitVector3D linearDirection,
     double linearSpeed)
     : this(originCoordinateSystem, angularAxis.ScaleBy(angularSpeed), linearDirection.ScaleBy(linearSpeed))
 {
 }
        // movement in xyz
        // move in a direction (supposedly a unit vector) for N meters
        public void MoveInDirection(UnitVector3D direction, double meters)
        {
            // move in current direction for this many meters
            // what is the current unit vector for heading?
            Vector3D movement = direction.ScaleBy(meters);  // movement vector, and then add to current position

            P.X += movement.X;
            P.Y += movement.Y;
            P.Z += movement.Z;
        }
Exemple #5
0
    protected void HScaleRotate(object sender, EventArgs e)
    {
        double       ang       = hscaleRot.Value * Math.PI;
        double       dx        = Math.Sin(ang) * Math.Sin(Y_ANG);
        double       dy        = Math.Cos(Y_ANG);
        double       dz        = Math.Cos(ang) * Math.Sin(Y_ANG);
        UnitVector3D norm      = new UnitVector3D(dx, dy, dz);
        Point3D      rootPoint = norm.ScaleBy(hscaleDist.Value).ToPoint3D();

        proj = new Plane(rootPoint, norm);
        RenderRoot();
    }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rectangle3D"/> struct.
        /// </summary>
        /// <param name="origin">The origin of the rectangle.</param>
        /// <param name="widthAxis">The horizontal width axis of the rectangle.</param>
        /// <param name="heightAxis">The vertical height axis of the rectangle.</param>
        /// <param name="left">The left edge of the rectangle (relative to origin along the width axis).</param>
        /// <param name="bottom">The bottom edge of the rectangle (relative to origin along the height axis).</param>
        /// <param name="width">The width of the rectangle (must be positive).</param>
        /// <param name="height">The height of the rectangle (must be positive).</param>
        /// <remarks>
        /// The edges of the rectangle are aligned to the specified width and height axes, which must be perpendicular.
        /// </remarks>
        public Rectangle3D(
            Point3D origin,
            UnitVector3D widthAxis,
            UnitVector3D heightAxis,
            double left,
            double bottom,
            double width,
            double height)
        {
            if (!widthAxis.IsPerpendicularTo(heightAxis, 0.001))
            {
                throw new ArgumentException("The width and height axes must be perpendicular to each other.");
            }

            if (width < 0 || height < 0)
            {
                throw new ArgumentException("Width and height must be non-negative values");
            }

            if (width == 0 || height == 0)
            {
                this.IsDegenerate = true;
            }
            else
            {
                this.IsDegenerate = false;
            }

            this.Width      = width;
            this.Height     = height;
            this.BottomLeft = origin + widthAxis.ScaleBy(left) + heightAxis.ScaleBy(bottom);
            var widthVector  = widthAxis.ScaleBy(width);
            var heightVector = heightAxis.ScaleBy(height);

            this.BottomRight = this.BottomLeft + widthVector;
            this.TopLeft     = this.BottomLeft + heightVector;
            this.TopRight    = this.TopLeft + widthVector;
        }
 public Vector3D ScaleBy()
 {
     return(UnitVector3D1.ScaleBy(2));
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AngularVelocity3D"/> struct.
 /// </summary>
 /// <param name="originRotation">The origin of rotation.</param>
 /// <param name="axis">The axis of velocity.</param>
 /// <param name="speed">The angular speed (radians/time).</param>
 public AngularVelocity3D(Matrix <double> originRotation, UnitVector3D axis, double speed)
     : this(originRotation, axis.ScaleBy(speed))
 {
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinearVelocity3D"/> struct.
 /// </summary>
 /// <param name="origin">The origin of the velocity.</param>
 /// <param name="unitVector">The unit vector indicating the direction of velocity.</param>
 /// <param name="speed">The speed in the specified direction.</param>
 public LinearVelocity3D(Point3D origin, UnitVector3D unitVector, double speed)
     : this(origin, unitVector.ScaleBy(speed))
 {
 }