using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MECF.Framework.Common.TwinCat { public class Scaling { public Scaling(double x1, double x2, double y1, double y2) { _scaleA=(y1-y2)/(x1-x2); _scaleB = y1 - _scaleA * x1; } private double _scaleA; private double _scaleB; public double CalculateYByX(double x) { return Math.Round((_scaleA * x + _scaleB),2); } public int CaculateXByY(double y) { return (int)Math.Round(((y - _scaleB) / _scaleA)); } } }