Fix Point Mapping.

This commit is contained in:
2026-03-10 23:42:21 -04:00
parent 05b9ac3897
commit d4c97aaf0a

View File

@@ -25,11 +25,17 @@ namespace MarketData.CNNProcessing
// MapPoint will both scale the given point and translate the given point from an upper left origin system to a bottom left origin system
public Point MapPoint(Point sourcePoint)
{
Point mappedPoint=new Point((int)((sourcePoint.X-XDataExtentMin)*XScalingFactor),(int)(Height-((sourcePoint.Y-YDataExtentMin)*YScalingFactor)));
mappedPoint.X+=(int)XMargin; // offset by the xMargin
mappedPoint.Y-=(int)YMargin; // offset by the yMargin
return mappedPoint;
int x = (int)((sourcePoint.X - XDataExtentMin) * XScalingFactor + XMargin);
int y = (int)(Height - 1 - ((sourcePoint.Y - YDataExtentMin) * YScalingFactor) - YMargin);
// clamp to bounds
x = Math.Max(0, Math.Min(x, (int)Width - 1));
y = Math.Max(0, Math.Min(y, (int)Height - 1));
return new Point(x, y);
}
// TranslatePoint will only translate the given point from an upper left origin system to a bottom left origin system
public Point TranslatePoint(Point sourcePoint)
{