1////////////////////////////////////////////////////////////////////////////////
2// //
3// This software is supplied under the terms of a license agreement or //
4// nondisclosure agreement with Mitov Software and may not be copied //
5// or disclosed except in accordance with the terms of that agreement. //
6// Copyright(c) 2002-2016 Mitov Software. All Rights Reserved. //
7// //
8////////////////////////////////////////////////////////////////////////////////
9
10#ifndef _MITOV_TRIANGLE_GENERATOR_h
11#define _MITOV_TRIANGLE_GENERATOR_h
12
13#include <Mitov.h>
14#include "Mitov_BasicGenerator.h"
15
16namespace Mitov
17{
18//---------------------------------------------------------------------------
19 class TriangleAnalogGenerator : public Mitov::AsymmetricGenerator<float>
20 {
21 typedef Mitov::AsymmetricGenerator<float> inherited;
22
23 protected:
24 virtual void CalculateValue() override
25 {
26 float AAssymetryPount = 0.5 + Asymmetry / 2;
27 if( FPhase < AAssymetryPount )
28 FValue = Offset - Amplitude + Amplitude * 2 * ( FPhase / AAssymetryPount );
29
30 else
31 FValue = Offset - Amplitude + Amplitude * 2 * ( 1 - (( FPhase - AAssymetryPount ) / ( 1 - AAssymetryPount )));
32
33 }
34
35 public:
36 TriangleAnalogGenerator() :
37 inherited( 0.5, 0.5 )
38 {
39 }
40
41 };
42//---------------------------------------------------------------------------
43 class TriangleIntegerGenerator : public Mitov::AsymmetricGenerator<long>
44 {
45 typedef Mitov::AsymmetricGenerator<long> inherited;
46
47 protected:
48 virtual void CalculateValue() override
49 {
50 float AAssymetryPount = 0.5 + Asymmetry / 2;
51 if( FPhase < AAssymetryPount )
52 FValue = ( Offset - Amplitude + ((float)Amplitude) * 2 * ( FPhase / AAssymetryPount ) ) + 0.5;
53
54 else
55 FValue = ( Offset - Amplitude + ((float)Amplitude) * 2 * ( 1 - (( FPhase - AAssymetryPount ) / ( 1 - AAssymetryPount ))) ) + 0.5;
56
57 }
58
59 public:
60 TriangleIntegerGenerator() :
61 inherited( 1000, 0 )
62 {
63 }
64
65 };
66//---------------------------------------------------------------------------
67 class TriangleUnsignedGenerator : public Mitov::AsymmetricGenerator<unsigned long>
68 {
69 typedef Mitov::AsymmetricGenerator<unsigned long> inherited;
70
71 protected:
72 virtual void CalculateValue() override
73 {
74 float AAssymetryPount = 0.5 + Asymmetry / 2;
75 if( FPhase < AAssymetryPount )
76 FValue = ( Offset - Amplitude + ((float)Amplitude) * 2 * ( FPhase / AAssymetryPount ) ) + 0.5;
77
78 else
79 FValue = ( Offset - Amplitude + ((float)Amplitude) * 2 * ( 1 - (( FPhase - AAssymetryPount ) / ( 1 - AAssymetryPount ))) ) + 0.5;
80
81 }
82
83 public:
84 TriangleUnsignedGenerator() :
85 inherited( 1000, 1000 )
86 {
87 }
88
89 };
90//---------------------------------------------------------------------------
91}
92
93#endif