2
* Copyright (C) 2005 Terence M. Welsh
4
* This file is part of Implicit.
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.
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.
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
30
class impKnot : public impShape{
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
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;
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;
59
int getNumCoils(){return coils;}
60
void setNumTwists(int t){
62
twistsf = float(twists);
63
twistsOverCoils = twistsf / coilsf;
65
int getNumTwists(){return twists;}
66
virtual float value(float* position);
67
virtual void center(float* position);
68
virtual void addCrawlPoint(impCrawlPointVector &cpv);