OSCAT Forum

oscat.lib => Bestehende Module / Existing Modules => Thema gestartet von: hugo am 01. Januar 2007, 16:12:15

Titel: lineare gleichung mit 2 wertepaaren
Beitrag von: hugo am 01. Januar 2007, 16:12:15
eine lineare gleichung y= ax + b die durch zwei wertepaare x1/y1 und x2/y2 beschrieben wird.

FUNCTION F_Lin2 : REAL
VAR_INPUT
   X : REAL;
   X1: REAL;
   Y1 : REAL;
   X2 : REAL;
   Y2 : REAL;
END_VAR
VAR

END_VAR

(*
version 1.0   1 jan 2007
programmer    hugo
tested by      tobias

this function calculates the linear equation f_lin = a*x + b given by two points x1/y1 and x2/y2.

*)

F_Lin2 := (Y2 - Y1) / (X2 - X1) * X + (Y1 * X1 - Y2 * X1) / (X2 - X1) + Y1;