// Copyright 1999
// College of Computer Science
// Northeastern University Boston MA 02115

// This software may be used for educational purposes as long as this copyright
// notice is retained at the top of all files

// Should this software be modified, the words "Modified from Original" must be
// included as a comment below this notice

// All publication rights are retained.  This software or its documentation may
// not be published in any media either in whole or in part.

///////////////////////////////////////////////////////////////////////////////

//	Scale.cpp

///////////////////////////////////////////////////////////////////////////////

#include "CoreTools.h"				// needed for core tools compile in Win32

#include "Scale.h"

// LinearScale functions

// See MathUtil.h

LinearScale& LinearScale::Set(double a, double b, short ia, short ib) {

	factor = ComputeFactor(a, b, ia, ib);
	offset = ComputeOffset(a, b, ia, ib, factor);

	return *this;
}


// LogScale functions

// map interval a, b to ia, ib

LogScale& LogScale::Set(double a, double b, short ia, short ib) {
	// error if a <= 0 or b <= 0 since logarithm is invalid
	if ((a <= 0) || (b <=0))
		throw string("LogScale Set passed domain bounds <= 0");

	// if ok then set linear scale S usings logs of a and b
	S.Set(log(a), log(b), ia, ib);

	return *this;
}

