~ubuntu-branches/ubuntu/precise/primrose/precise

« back to all changes in this revision

Viewing changes to minorGems/math/expression/CosExpression.h

  • Committer: Bazaar Package Importer
  • Author(s): Paul Wise
  • Date: 2009-04-06 19:26:56 UTC
  • Revision ID: james.westby@ubuntu.com-20090406192656-cri7503gebyvfl8t
Tags: upstream-5+dfsg1
ImportĀ upstreamĀ versionĀ 5+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Modification History 
 
3
 *
 
4
 * 2003-April-28   Jason Rohrer
 
5
 * Created.
 
6
 */
 
7
 
 
8
 
 
9
#ifndef COS_EXPRESSION_INCLUDED
 
10
#define COS_EXPRESSION_INCLUDED 
 
11
 
 
12
#include "Expression.h" 
 
13
#include "UnaryOperationExpression.h" 
 
14
 
 
15
#include <math.h>
 
16
 
 
17
/**
 
18
 * Expression implementation of a unary cos operation. 
 
19
 *
 
20
 * @author Jason Rohrer 
 
21
 */
 
22
class CosExpression : public UnaryOperationExpression { 
 
23
    
 
24
    public:
 
25
        
 
26
        /**
 
27
         * Constructs a unary cos operation expression.
 
28
         *
 
29
         * Argument is destroyed when the class is destroyed.
 
30
         *
 
31
         * @param inArgument the argument.
 
32
         */
 
33
        CosExpression( Expression *inArgument );
 
34
        
 
35
        
 
36
        /**
 
37
         * A static version of getID().
 
38
         */
 
39
        static long staticGetID();
 
40
        
 
41
        
 
42
        // implements the Expression interface
 
43
        virtual double evaluate();
 
44
        virtual long getID();
 
45
        virtual void print();
 
46
        virtual Expression *copy();
 
47
        
 
48
    protected:
 
49
        static long mID;
 
50
        
 
51
    };
 
52
 
 
53
 
 
54
 
 
55
// static init
 
56
long CosExpression::mID = 11;
 
57
 
 
58
 
 
59
 
 
60
inline CosExpression::CosExpression( Expression *inArgument ) 
 
61
    : UnaryOperationExpression( inArgument ) {
 
62
    
 
63
    }
 
64
 
 
65
 
 
66
 
 
67
inline double CosExpression::evaluate() {
 
68
    return cos( mArgument->evaluate() );
 
69
    }
 
70
 
 
71
 
 
72
 
 
73
inline long CosExpression::getID() {    
 
74
    return mID;
 
75
    }    
 
76
 
 
77
 
 
78
 
 
79
inline long CosExpression::staticGetID() {
 
80
    return mID;
 
81
    }
 
82
 
 
83
 
 
84
 
 
85
inline void CosExpression::print() {
 
86
    printf( "( cos" );
 
87
    
 
88
    mArgument->print();
 
89
    printf( " )" );
 
90
    }
 
91
            
 
92
 
 
93
 
 
94
inline Expression *CosExpression::copy() {
 
95
    CosExpression *copy =
 
96
        new CosExpression( mArgument->copy() );
 
97
    
 
98
    return copy;
 
99
    }        
 
100
 
 
101
 
 
102
    
 
103
#endif