public PointF WorldToScreen(ViewModel.Point point) { return(new PointF { X = (float)((point.X - MidWorld_.X) * scale_ + 0.5 * Width), Y = (float)((point.Y - MidWorld_.Y) * scale_ + 0.5 * Height), }); }
public ViewPort(int screenWidth, int screenHeight, ViewModel.Point MinWorld, ViewModel.Point MaxWorld) { Width = screenWidth; Height = screenHeight; MinWorld_ = MinWorld; MaxWorld_ = MaxWorld; CalulateTransformation(); }
private void CalulateTransformation() { const double PercetageOfScreenUse = 0.9; scale_ = PercetageOfScreenUse * Math.Min( Width / (MaxWorld_.X - MinWorld_.X), Height / (MaxWorld_.Y - MinWorld_.Y)); MidWorld_ = new ViewModel.Point { X = 0.5 * MinWorld_.X + 0.5 * MaxWorld_.X, Y = 0.5 * MinWorld_.Y + 0.5 * MaxWorld_.Y, Z = 0.5 * MinWorld_.Z + 0.5 * MaxWorld_.Z }; }