~ubuntu-branches/ubuntu/gutsy/rss-glx/gutsy

« back to all changes in this revision

Viewing changes to reallyslick/include/Implicit/impKnot.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-11-30 18:21:27 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051130182127-5iww7elbiyzej1lk
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005  Terence M. Welsh
 
3
 *
 
4
 * This file is part of Implicit.
 
5
 *
 
6
 * Implicit is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License version 2.1 as published by the Free Software Foundation.
 
9
 *
 
10
 * Implicit is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 */
 
19
 
 
20
 
 
21
#ifndef IMPKNOT_H
 
22
#define IMPKNOT_H
 
23
 
 
24
 
 
25
 
 
26
#include "impShape.h"
 
27
 
 
28
 
 
29
 
 
30
class impKnot : public impShape{
 
31
private:
 
32
        float radius1;
 
33
        float radius2;
 
34
        int coils, twists;  // integer number of coils and twists, respectively
 
35
        float coilsf, twistsf;  // floating point versions of n and m
 
36
        float twistsOverCoils, lat_offset;  // precomputed variables
 
37
 
 
38
public:
 
39
        impKnot(){
 
40
                radius1 = 1.0f; radius2 = 0.5f; thickness = 0.1f;
 
41
                coils = 3; coilsf = float(coils); twists = 2; twistsf = float(twists);
 
42
                thicknessSquared = thickness * thickness;
 
43
                twistsOverCoils = twistsf / coilsf;
 
44
                lat_offset = 6.28318530718f / coilsf;
 
45
        }
 
46
        ~impKnot(){}
 
47
        // position is an array of 3 floats
 
48
        // returns the field strenth of this sphere at a given position
 
49
        void setRadius1(float r){radius1 = r;}
 
50
        float getRadius1(){return radius1;}
 
51
        void setRadius2(float r){radius2 = r;}
 
52
        float getRadius2(){return radius2;}
 
53
        void setNumCoils(int c){
 
54
                coils = (c<1 ? 1 : c);  // coils must be greater than 1
 
55
                coilsf = float(coils);
 
56
                twistsOverCoils = twistsf / coilsf;
 
57
                lat_offset = 6.28318530718f / coilsf;
 
58
        }
 
59
        int getNumCoils(){return coils;}
 
60
        void setNumTwists(int t){
 
61
                twists = t;
 
62
                twistsf = float(twists);
 
63
                twistsOverCoils = twistsf / coilsf;
 
64
        }
 
65
        int getNumTwists(){return twists;}
 
66
        virtual float value(float* position);
 
67
        virtual void center(float* position);
 
68
        virtual void addCrawlPoint(impCrawlPointVector &cpv);
 
69
};
 
70
 
 
71
 
 
72
 
 
73
#endif