aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/kiwisolver/py2/kiwi/strength.h
blob: b077f3e17c167d6a02640e3eeaf696b50c81b738 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2017, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
| The full license is in the file COPYING.txt, distributed with this software.
|----------------------------------------------------------------------------*/
#pragma once
#include <algorithm>


namespace kiwi
{

namespace strength
{

inline double create( double a, double b, double c, double w = 1.0 )
{
	double result = 0.0;
	result += std::max( 0.0, std::min( 1000.0, a * w ) ) * 1000000.0;
	result += std::max( 0.0, std::min( 1000.0, b * w ) ) * 1000.0;
	result += std::max( 0.0, std::min( 1000.0, c * w ) );
	return result;
}


const double required = create( 1000.0, 1000.0, 1000.0 );

const double strong = create( 1.0, 0.0, 0.0 );

const double medium = create( 0.0, 1.0, 0.0 );

const double weak = create( 0.0, 0.0, 1.0 );


inline double clip( double value )
{
	return std::max( 0.0, std::min( required, value ) );
}

} // namespace strength

} // namespace kiwi