Fix Point Mapping.
This commit is contained in:
@@ -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
|
// 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)
|
public Point MapPoint(Point sourcePoint)
|
||||||
{
|
{
|
||||||
Point mappedPoint=new Point((int)((sourcePoint.X-XDataExtentMin)*XScalingFactor),(int)(Height-((sourcePoint.Y-YDataExtentMin)*YScalingFactor)));
|
int x = (int)((sourcePoint.X - XDataExtentMin) * XScalingFactor + XMargin);
|
||||||
mappedPoint.X+=(int)XMargin; // offset by the xMargin
|
int y = (int)(Height - 1 - ((sourcePoint.Y - YDataExtentMin) * YScalingFactor) - YMargin);
|
||||||
mappedPoint.Y-=(int)YMargin; // offset by the yMargin
|
|
||||||
return mappedPoint;
|
// 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
|
// TranslatePoint will only translate the given point from an upper left origin system to a bottom left origin system
|
||||||
public Point TranslatePoint(Point sourcePoint)
|
public Point TranslatePoint(Point sourcePoint)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user