From 71a4b02c7e9a2587759fd40092d1bdcfef648eff Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 20:56:01 +1000 Subject: * Minor commit, added two new math utility functions. --- OpenSim/Framework/Util.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 58344f3..45b5a10 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -70,6 +70,39 @@ namespace OpenSim.Framework public static readonly Regex UUIDPattern = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); + /// + /// Linear interpolates B<->C using percent A + /// + /// + /// + /// + /// + public static double lerp(double a, double b, double c) + { + return (b*a) + (c*(1 - a)); + } + + /// + /// Bilinear Interpolate, see Lerp but for 2D using 'percents' X & Y. + /// Layout: + /// A B + /// C D + /// A<->C = Y + /// C<->D = X + /// + /// + /// + /// + /// + /// + /// + /// + public static double lerp2D(double x, double y, double a, double b, double c, double d) + { + return lerp(y, lerp(x, a, b), lerp(x, c, d)); + } + + /// /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) /// -- cgit v1.1