/// <summary> /// Get maximum internal rectangle smaller than the rectangle specified by 'l' and 's' /// Each axis value in 's' must be positive. /// </summary> public static Rect3D MaxSmallerRect(LocationF l, Size3DF s) { Location loc = Location.Ceiling(l); int x2 = (int)Math.Floor(l.X + s.sx); int y2 = (int)Math.Floor(l.Y + s.sy); int z2 = (int)Math.Floor(l.Z + s.sz); Size3D size = new Size3D(x2 - loc.X, y2 - loc.Y, z2 - loc.Z); return(new Rect3D(loc, size)); }
/// <summary> /// Get horizontal <code>Direction</code> toward specified <code>Location</code> 'to'. /// Retrun value is the nearest one in 16 directions. /// </summary> /// <param name="to"></param> /// <returns></returns> public Direction16 GetDirectionTo(LocationF to) { double v = Math.Atan2(to.Y - Y, to.X - X) / Math.PI; if (v < 0) { v += 2.5; } else { v += 0.5; } // 180deg = 1, 22.5deg=1/8. so multiply v 8 times to make 22.5deg=1 int n = (int)Math.Round(v * 8); return(Direction.GetByAngle(n)); }
/// Convert each coordinate to integer which is largest but not greater than original. /// public static Location Floor(LocationF l) { return(new Location((int)Math.Floor(l.X), (int)Math.Floor(l.Y), (int)Math.Floor(l.Z))); }
/// Convert each coordinate to integer which is smallest but not lesser than original. /// public static Location Ceiling(LocationF l) { return(new Location((int)Math.Ceiling(l.X), (int)Math.Ceiling(l.Y), (int)Math.Ceiling(l.Z))); }
public double GetPlaneDistanceTo(LocationF to) { return((to - this).ValueInPlane); }
public double GetDistanceTo(LocationF to) { return((to - this).Value); }
public Size3DF(LocationF l) { sx = l.X; sy = l.Y; sz = l.Z; }