/// <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 bool IsPerpendicularToVector3D() { return(UnitVector3D1.IsPerpendicularTo(Vector3D, 2)); }