IWindow3D

Namespace: Digi21.Math
Assembly: Digi21.DigiNG

Three-dimensional window (axis-aligned box): minimum and maximum coordinates, dimensions, center and cardinal points. Entities and drawing files implement this interface to expose the box they occupy.

public interface IWindow3D

Types implementing the interface:

An uninitialized window has Xmin set to null. Window3D throws InvalidOperationException when reading Width, Height, Depth, Center or one of the eight cardinal points of an uninitialized window. Check Valid before reading Width, Height, Depth, Center or one of the eight cardinal points.

Properties

Property Description
double? Xmin Minimum X coordinate, or null if the window is uninitialized.
double Ymin Minimum Y coordinate.
double Zmin Minimum Z coordinate.
double Xmax Maximum X coordinate.
double Ymax Maximum Y coordinate.
double Zmax Maximum Z coordinate.
bool Valid In Window3D, true if Xmin is not null and each minimum is less than or equal to its maximum.
double Width Xmax - Xmin.
double Height Ymax - Ymin.
double Depth Zmax - Zmin.
Point3D Center Box center.
Point3D NW Northwest corner: (Xmin, Ymax, Zmin).
Point3D N Midpoint of the north side.
Point3D NE Northeast corner: (Xmax, Ymax, Zmin).
Point3D E Midpoint of the east side.
Point3D SE Southeast corner: (Xmax, Ymin, Zmin).
Point3D S Midpoint of the south side.
Point3D SW Southwest corner: (Xmin, Ymin, Zmin).
Point3D W Midpoint of the west side.

Example

The Muestra method takes any IWindow3D (a Window3D, entity or drawing file) and reads dimensions only if the window is valid:

using Digi21.Math;

Point3D[] puntos =
{
    new Point3D(440000, 4470000, 612.4),
    new Point3D(440250, 4470100, 655.0),
    new Point3D(440120, 4469900, 630.8),
};

// A Window3D created with new Window3D() is uninitialized: Xmin is null.
var caja = new Window3D();
foreach (var punto in puntos)
    caja.Union(punto);

Muestra(caja);

// Contains(Point3D) compares X, Y and Z; Intersect2D compares only X and Y.
var fueraDeCota = new Point3D(440100, 4470000, 700);
Console.WriteLine(caja.Contains(fueraDeCota));      // False
Console.WriteLine(caja.Intersect2D(fueraDeCota));   // True

var otra = new Window3D(440200, 4470050, 600, 440400, 4470300, 640);
Console.WriteLine(caja.Intersect(otra));            // True

var total = Window3D.Union(caja, otra);
Muestra(total);

// Conversion to Window2D discards Zmin and Zmax.
var plano = (Window2D)total;
Console.WriteLine($"{plano.Width} x {plano.Height}");

static void Muestra(IWindow3D ventana)
{
    if (!ventana.Valid)
    {
        Console.WriteLine("Ventana no válida");
        return;
    }

    Console.WriteLine($"X: {ventana.Xmin} a {ventana.Xmax}, Y: {ventana.Ymin} a {ventana.Ymax}, Z: {ventana.Zmin} a {ventana.Zmax}");
    Console.WriteLine($"{ventana.Width} x {ventana.Height} x {ventana.Depth}, centro {ventana.Center}");
}