コード例 #1
0
ファイル: Box.cs プロジェクト: terminar/PresetMagician
        /// <summary>
        ///
        /// </summary>
        /// <param name="point">
        ///     An n-dimensional point for one "corner".
        /// </param>
        /// <param name="vector">
        ///     An n-dimensional vector to the opposite "corner".
        /// </param>
        public Box(IPoint <T> point, IVector <T> vector)
        {
            int dimensions = point.Dimensions;

            if (dimensions != vector.Dimensions)
            {
                throw new ArgumentException("The point and the vector must agree on dimensionality.");
            }

            _intervals = new Interval <T> [dimensions];
            for (int dimension = 0; dimension < dimensions; dimension++)
            {
                dynamic start = point.GetCoordinate(dimension);
                dynamic end   = start + vector.GetDelta(dimension);
                if (start <= end)
                {
                    _intervals[dimension] = new Interval <T>(start, true, end, true);
                }
                else
                {
                    _intervals[dimension] = new Interval <T>(end, true, start, true);
                }
            }
        }