Globe Fly tool
PointZ.cs
// Copyright 2012 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 

using System;
using System.Collections.Generic;
using System.Text;

namespace GlobeFlyTool
{
    public class PointZ
    {
        public double x;
        public double y;
        public double z;

        public PointZ()
        {
            x = 0;
            y = 0;
            z = 0;
        }
        public PointZ(double x, double y, double z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public double Norm()
        {
            double val = Math.Sqrt((this.x * this.x) +
                                   (this.y * this.y) +
                                   (this.z * this.z));
            return val;
        }

        public static PointZ operator +(PointZ p1, PointZ p2)
        {
            PointZ newPoint = new PointZ();
            newPoint.x = p1.x + p2.x;
            newPoint.y = p1.y + p2.y;
            newPoint.z = p1.z + p2.z;
            return newPoint;
        }

        public static PointZ operator-(PointZ p1, PointZ p2)
        {
            PointZ newPoint = new PointZ();
            newPoint.x = p1.x - p2.x;
            newPoint.y = p1.y - p2.y;
            newPoint.z = p1.z - p2.z;
            return newPoint;
        }

        public static PointZ operator*(PointZ p, double factor)
        {
            PointZ newPoint = new PointZ(factor * p.x, factor * p.y, factor * p.z);
            return newPoint;
        }
    }
}