Exemplo n.º 1
0
        public static Coord3d compute(Coord3d p0, Coord3d p1, Coord3d p2)
        {
            Vector3d v1   = new Vector3d(p0, p1);
            Vector3d v2   = new Vector3d(p1, p2);
            Coord3d  norm = v1.cross(v2);
            double   d    = norm.distance(Coord3d.ORIGIN);

            return(norm.divide(d));
        }
Exemplo n.º 2
0
 public Coord3d[] toArray()
 {
     Coord3d[] array = new Coord3d[m_x.Length];
     for (int iCoord = 0; iCoord <= m_x.Length - 1; iCoord++)
     {
         array[iCoord] = new Coord3d(m_x[iCoord], m_y[iCoord], m_z[iCoord]);
     }
     return(array);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Computes the sinus of the angle
        /// </summary>
        public double sin()
        {
            Coord3d  c2 = new Coord3d(x2, y2, z2);
            Vector3d v1 = new Vector3d(x1, y1, z1, x2, y2, z2);
            Vector3d v3 = new Vector3d(x3, y3, z3, x2, y2, z2);
            Coord3d  c4 = v1.cross(v3).@add(c2);
            Vector3d v4 = new Vector3d(c4, c2);

            return((c4.z >= 0 ? 1 : -1) * v4.norm() / (v1.norm() * v3.norm()));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Computes the vectorial product of the current and the given vector.
        /// The result is a vector defined as a Coord3d, that is perpendicular to
        /// the plan induced by current vector and vector V.
        /// </summary>
        public Coord3d cross(Vector3d v)
        {
            Coord3d v1 = this.vector;
            Coord3d v2 = v.vector;
            Coord3d v3 = new Coord3d();

            v3.x = v1.y * v2.z - v1.z * v2.y;
            v3.y = v1.z * v2.x - v1.x * v2.z;
            v3.z = v1.x * v2.y - v1.y * v2.x;
            return(v3);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Return a copy of the current bounding box after shitfing all limits
        /// Shifting does not modify the current bounding box.
        /// </summary>
        /// <remarks>Current object is not modified, a new one is created.</remarks>
        public BoundingBox3d shift(Coord3d offset)
        {
            BoundingBox3d b = new BoundingBox3d();

            b.m_xmax = m_xmax + offset.x;
            b.m_xmin = m_xmin + offset.x;
            b.m_ymax = m_ymax + offset.y;
            b.m_ymin = m_ymin + offset.y;
            b.m_zmax = m_zmax + offset.z;
            b.m_zmin = m_zmin + offset.z;
            return(b);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Return a copy of the current bounding box after scaling all limits relative to 0,0,0
        /// Scaling does not modify the current bounding box.
        /// </summary>
        /// <remarks>Current object is not modified, a new one is created.</remarks>
        public BoundingBox3d scale(Coord3d factors)
        {
            BoundingBox3d b = new BoundingBox3d();

            b.m_xmax = m_xmax * factors.x;
            b.m_xmin = m_xmin * factors.x;
            b.m_ymax = m_ymax * factors.y;
            b.m_ymin = m_ymin * factors.y;
            b.m_zmax = m_zmax * factors.z;
            b.m_zmin = m_zmin * factors.z;
            return(b);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Multiply components of the current <see cref="Coord3d"/> with values of another <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to multiply with</param>
 public void multiplySelf(Coord3d coord)
 {
     this.x *= coord.x;
     this.y *= coord.y;
     this.z *= coord.z;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Multiply components of another <see cref="Coord3d"/> with components of the current <see cref="Coord3d"/> and return the result
 /// in a new <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to multiply with</param>
 /// <remarks>Current object is not modified</remarks>
 public Coord3d multiply(Coord3d coord)
 {
     return(new Coord3d(this.x * coord.x, this.y * coord.y, this.z * coord.z));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds a <see cref="Coord3d"/> point to the bounding box, and enlarge the bounding
 /// box if this points lies outside of it.
 /// </summary>
 public void @add(Coord3d p)
 {
     this.@add(p.x, p.y, p.z);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Returns the dot product of current coordinate with another coordinate
 /// </summary>
 public double dot(Coord3d coord)
 {
     return(x * coord.x + y * coord.y + z * coord.z);
 }
Exemplo n.º 11
0
 public Coord3d(Coord3d c, double zi) : this(c.x, c.y, zi)
 {
 }
Exemplo n.º 12
0
 /// <summary>
 /// Create an angle, described by three coordinates.
 /// The angle is supposed to be on p2
 /// </summary>
 public Angle3d(Coord3d p1, Coord3d p2, Coord3d p3) : this(p1.x, p2.x, p3.x, p1.y, p2.y, p3.y, p1.z, p2.z, p3.z)
 {
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initialize a BoundingBox with given centre and edgeLength (equals in all directions)
 /// </summary>
 public BoundingBox3d(Coord3d center, double edgeLength) : this(center.x - edgeLength / 2, center.x + edgeLength / 2, center.y - edgeLength / 2, center.y + edgeLength / 2, center.z - edgeLength / 2, center.z + edgeLength / 2)
 {
 }
Exemplo n.º 14
0
 /// <summary>
 /// Return true if <paramref name="aPoint"/> is contained in this box.
 /// </summary>
 public bool contains(Coord3d aPoint)
 {
     return(m_xmin <= aPoint.x & aPoint.x <= m_xmax & m_ymin <= aPoint.y & aPoint.y <= m_ymax & m_zmin <= aPoint.z & aPoint.z <= m_zmax);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Divide components of the current <see cref="Coord3d"/> by components of another <see cref="Coord3d"/> and return the result
 /// in a new <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to divide with</param>
 /// <remarks>Current object is not modified</remarks>
 public Coord3d divide(Coord3d coord)
 {
     return(new Coord3d(this.x / coord.x, this.y / coord.y, this.z / coord.z));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Divide components of the current <see cref="Coord3d"/> by values of another <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to divide by</param>
 public void divideSelf(Coord3d coord)
 {
     this.x /= coord.x;
     this.y /= coord.y;
     this.z /= coord.z;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Add values of another <see cref="Coord3d"/> to all components of the current <see cref="Coord3d"/> and return the result
 /// in a new <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to add</param>
 /// <remarks>Current object is not modified</remarks>
 public Coord3d @add(Coord3d coord)
 {
     return(new Coord3d(this.x + coord.x, this.y + coord.y, this.z + coord.z));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Compute the distance between two coordinates.
 /// </summary>
 /// <returns></returns>
 /// <remarks></remarks>
 public double distance(Coord3d coord)
 {
     return(Math.Sqrt(Math.Pow((this.x - coord.x), 2) + Math.Pow((this.y - coord.y), 2) + Math.Pow((this.z - coord.z), 2)));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Add values of another <see cref="Coord3d"/> to all components of the current <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to add</param>
 public void addSelf(Coord3d coord)
 {
     this.x += coord.x;
     this.y += coord.y;
     this.z += coord.z;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Assuming current coordinate is in cartesian system, returns a new coordinate in polar system
 /// </summary>
 /// <remarks>Current object is not modified</remarks>
 public Coord3d interpolateTo(Coord3d coord, double f)
 {
     return(new Coord3d(x + (coord.x - x) * f, y + (coord.y - y) * f, z + (coord.z - z) * f));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Substract values of another <see cref="Coord3d"/> to all components of the current <see cref="Coord3d"/> and return the result
 /// in a new <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to substract</param>
 /// <remarks>Current object is not modified</remarks>
 public Coord3d substract(Coord3d coord)
 {
     return(new Coord3d(this.x - coord.x, this.y - coord.y, this.z - coord.z));
 }
Exemplo n.º 22
0
 public Vector3d(Coord3d p1, Coord3d p2) : this(p1.x, p2.x, p1.y, p2.y, p1.z, p2.z)
 {
 }
Exemplo n.º 23
0
 /// <summary>
 /// Substract values of another <see cref="Coord3d"/> to all components of the current <see cref="Coord3d"/>.
 /// </summary>
 /// <param name="coord">Coordinate with values to substract</param>
 public void substractSelf(Coord3d coord)
 {
     this.x -= coord.x;
     this.y -= coord.y;
     this.z -= coord.z;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Compute the distance between two coordinates.
 /// </summary>
 public double distance(Coord3d c)
 {
     return(this.Center.distance(c));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Set all values of Coord3d
 /// </summary>
 /// <returns>Self</returns>
 /// <remarks></remarks>
 public Coord3d set(Coord3d another)
 {
     return(setvalues(another.x, another.y, another.z));
 }