~ubuntu-branches/debian/sid/geogebra/sid

« back to all changes in this revision

Viewing changes to geogebra/kernel/AlgoVertex.java

  • Committer: Package Import Robot
  • Author(s): Giovanni Mascellani
  • Date: 2012-01-10 11:37:41 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120110113741-satwohsd4de4ite1
Tags: 4.0.19.0+dfsg1-1
* New upstream version (closes: #649893).
* Update dependency: icedtea-plugin -> icedtea-netx-common (LP: #893007).
* New thumbnailer configuration compatible with Gnome 3.
* Package building is now managed by javahelper instead of upstream
  build.xml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
GeoGebra - Dynamic Mathematics for Everyone
3
 
http://www.geogebra.org
4
 
 
5
 
This file is part of GeoGebra.
6
 
 
7
 
This program is free software; you can redistribute it and/or modify it 
8
 
under the terms of the GNU General Public License as published by 
9
 
the Free Software Foundation.
10
 
 
11
 
*/
12
 
 
13
 
/*
14
 
 * AlgoVertex.java
15
 
 *
16
 
 * Created on 11. November 2001, 21:37
17
 
 */
18
 
 
19
 
package geogebra.kernel;
20
 
 
21
 
 
22
 
 
23
 
/**
24
 
 *
25
 
 * @author  Markus
26
 
 * @version 
27
 
 */
28
 
public class AlgoVertex extends AlgoElement {
29
 
 
30
 
    /**
31
 
         * 
32
 
         */
33
 
        private static final long serialVersionUID = 1L;
34
 
        private GeoConic c;  // input
35
 
    private GeoPoint [] vertex;  // output        
36
 
                                  
37
 
    transient private double temp1, temp2;
38
 
    private GeoVec2D b;
39
 
    private GeoVec2D [] eigenvec;
40
 
        
41
 
    AlgoVertex(Construction cons, String label, GeoConic c) {
42
 
        this(cons, c);
43
 
        GeoElement.setLabels(label, vertex);            
44
 
    }
45
 
    
46
 
    AlgoVertex(Construction cons, String [] labels, GeoConic c) {
47
 
        this(cons, c);
48
 
        GeoElement.setLabels(labels, vertex);            
49
 
    }
50
 
    
51
 
    AlgoVertex(Construction cons, GeoConic c) {
52
 
        super(cons);
53
 
        this.c = c;        
54
 
        vertex = new GeoPoint[4];       
55
 
        for (int i=0; i < vertex.length; i++) {
56
 
                vertex[i] = new GeoPoint(cons);
57
 
                // only first undefined point should be shown in algebra window 
58
 
                vertex[i].showUndefinedInAlgebraView(i == 0);
59
 
        }
60
 
        
61
 
        setInputOutput(); // for AlgoElement
62
 
        
63
 
        b = c.b;
64
 
        eigenvec = c.eigenvec;
65
 
                
66
 
        compute();                      
67
 
    }   
68
 
    
69
 
    protected String getClassName() {
70
 
        return "AlgoVertex";
71
 
    }
72
 
    
73
 
    // for AlgoElement
74
 
    public void setInputOutput() {
75
 
        input = new GeoElement[1];
76
 
        input[0] = c;        
77
 
        
78
 
        output = vertex;        
79
 
        setDependencies(); // done by AlgoElement
80
 
    }    
81
 
    
82
 
    GeoConic getConic() { return c; }
83
 
    GeoPoint [] getVertex() { return vertex; }    
84
 
        
85
 
    protected final void compute() {  
86
 
        switch (c.type) {
87
 
            case GeoConic.CONIC_CIRCLE:                                      
88
 
            case GeoConic.CONIC_ELLIPSE:
89
 
                temp1 = c.halfAxes[0] * eigenvec[0].x;
90
 
                temp2 = c.halfAxes[0] * eigenvec[0].y;
91
 
                vertex[0].setCoords(b.x - temp1, b.y - temp2, 1.0);
92
 
                vertex[1].setCoords(b.x + temp1, b.y + temp2, 1.0);
93
 
                
94
 
                temp1 = c.halfAxes[1] * eigenvec[1].x;
95
 
                temp2 = c.halfAxes[1] * eigenvec[1].y;
96
 
                vertex[2].setCoords( b.x - temp1, b.y - temp2, 1.0);
97
 
                vertex[3].setCoords( b.x + temp1, b.y + temp2, 1.0);   
98
 
                break;
99
 
                
100
 
            case GeoConic.CONIC_HYPERBOLA:
101
 
                temp1 = c.halfAxes[0] * eigenvec[0].x;
102
 
                temp2 = c.halfAxes[0] * eigenvec[0].y;
103
 
                vertex[0].setCoords(b.x - temp1, b.y - temp2, 1.0d);
104
 
                vertex[1].setCoords(b.x + temp1, b.y + temp2, 1.0d);
105
 
                // third and fourth vertex undefined
106
 
                vertex[2].setUndefined();
107
 
                vertex[3].setUndefined();                
108
 
                break;
109
 
                
110
 
            case GeoConic.CONIC_PARABOLA:
111
 
            case GeoConic.CONIC_PARALLEL_LINES:
112
 
            case GeoConic.CONIC_DOUBLE_LINE:
113
 
                vertex[0].setCoords(b.x, b.y, 1.0);
114
 
 
115
 
                // other vertex undefined
116
 
                vertex[1].setUndefined();
117
 
                vertex[2].setUndefined();
118
 
                vertex[3].setUndefined();
119
 
                break;
120
 
                
121
 
            default:
122
 
                // no vertex defined
123
 
                vertex[0].setUndefined();
124
 
                vertex[1].setUndefined();
125
 
                vertex[2].setUndefined();
126
 
                vertex[3].setUndefined();
127
 
        }
128
 
    }
129
 
    
130
 
    public final String toString() {
131
 
        StringBuffer sb = new StringBuffer();
132
 
        // Michael Borcherds 2008-03-30
133
 
        // simplified to allow better Chinese translation
134
 
        sb.append(app.getPlain("VertexOfA",c.getLabel()));
135
 
        
136
 
        return sb.toString();
137
 
    }
138
 
}
 
1
/* 
 
2
GeoGebra - Dynamic Mathematics for Everyone
 
3
http://www.geogebra.org
 
4
 
 
5
This file is part of GeoGebra.
 
6
 
 
7
This program is free software; you can redistribute it and/or modify it 
 
8
under the terms of the GNU General Public License as published by 
 
9
the Free Software Foundation.
 
10
 
 
11
*/
 
12
 
 
13
/*
 
14
 * AlgoVertex.java
 
15
 *
 
16
 * Created on 11. November 2001, 21:37
 
17
 */
 
18
 
 
19
package geogebra.kernel;
 
20
 
 
21
 
 
22
 
 
23
/**
 
24
 *
 
25
 * @author  Markus
 
26
 * @version 
 
27
 */
 
28
public class AlgoVertex extends AlgoElement {
 
29
 
 
30
    /**
 
31
         * 
 
32
         */
 
33
        private static final long serialVersionUID = 1L;
 
34
        private GeoConic c;  // input
 
35
    private GeoPoint [] vertex;  // output        
 
36
                                  
 
37
    transient private double temp1, temp2;
 
38
    private GeoVec2D b;
 
39
    private GeoVec2D [] eigenvec;
 
40
        
 
41
    AlgoVertex(Construction cons, String label, GeoConic c) {
 
42
        this(cons, c);
 
43
        GeoElement.setLabels(label, vertex);            
 
44
    }
 
45
    
 
46
    AlgoVertex(Construction cons, String [] labels, GeoConic c) {
 
47
        this(cons, c);
 
48
        GeoElement.setLabels(labels, vertex);            
 
49
    }
 
50
    
 
51
    AlgoVertex(Construction cons, GeoConic c) {
 
52
        super(cons);
 
53
        this.c = c;        
 
54
        vertex = new GeoPoint[4];       
 
55
        for (int i=0; i < vertex.length; i++) {
 
56
                vertex[i] = new GeoPoint(cons);
 
57
                // only first undefined point should be shown in algebra window 
 
58
                vertex[i].showUndefinedInAlgebraView(i == 0);
 
59
        }
 
60
        
 
61
        setInputOutput(); // for AlgoElement
 
62
        
 
63
        b = c.b;
 
64
        eigenvec = c.eigenvec;
 
65
                
 
66
        compute();                      
 
67
    }   
 
68
    
 
69
    public String getClassName() {
 
70
        return "AlgoVertex";
 
71
    }
 
72
    
 
73
    // for AlgoElement
 
74
    public void setInputOutput() {
 
75
        input = new GeoElement[1];
 
76
        input[0] = c;        
 
77
        
 
78
        output = vertex;        
 
79
        setDependencies(); // done by AlgoElement
 
80
    }    
 
81
    
 
82
    GeoConic getConic() { return c; }
 
83
    GeoPoint [] getVertex() { return vertex; }    
 
84
        
 
85
    protected final void compute() {  
 
86
        switch (c.type) {
 
87
            case GeoConic.CONIC_CIRCLE:                                      
 
88
            case GeoConic.CONIC_ELLIPSE:
 
89
                temp1 = c.halfAxes[0] * eigenvec[0].x;
 
90
                temp2 = c.halfAxes[0] * eigenvec[0].y;
 
91
                vertex[0].setCoords(b.x - temp1, b.y - temp2, 1.0);
 
92
                vertex[1].setCoords(b.x + temp1, b.y + temp2, 1.0);
 
93
                
 
94
                temp1 = c.halfAxes[1] * eigenvec[1].x;
 
95
                temp2 = c.halfAxes[1] * eigenvec[1].y;
 
96
                vertex[2].setCoords( b.x - temp1, b.y - temp2, 1.0);
 
97
                vertex[3].setCoords( b.x + temp1, b.y + temp2, 1.0);   
 
98
                break;
 
99
                
 
100
            case GeoConic.CONIC_HYPERBOLA:
 
101
                temp1 = c.halfAxes[0] * eigenvec[0].x;
 
102
                temp2 = c.halfAxes[0] * eigenvec[0].y;
 
103
                vertex[0].setCoords(b.x - temp1, b.y - temp2, 1.0d);
 
104
                vertex[1].setCoords(b.x + temp1, b.y + temp2, 1.0d);
 
105
                // third and fourth vertex undefined
 
106
                vertex[2].setUndefined();
 
107
                vertex[3].setUndefined();                
 
108
                break;
 
109
                
 
110
            case GeoConic.CONIC_PARABOLA:
 
111
            case GeoConic.CONIC_PARALLEL_LINES:
 
112
            case GeoConic.CONIC_DOUBLE_LINE:
 
113
                vertex[0].setCoords(b.x, b.y, 1.0);
 
114
 
 
115
                // other vertex undefined
 
116
                vertex[1].setUndefined();
 
117
                vertex[2].setUndefined();
 
118
                vertex[3].setUndefined();
 
119
                break;
 
120
                
 
121
            default:
 
122
                // no vertex defined
 
123
                vertex[0].setUndefined();
 
124
                vertex[1].setUndefined();
 
125
                vertex[2].setUndefined();
 
126
                vertex[3].setUndefined();
 
127
        }
 
128
    }
 
129
    
 
130
    public final String toString() {
 
131
        // Michael Borcherds 2008-03-30
 
132
        // simplified to allow better Chinese translation
 
133
        return app.getPlain("VertexOfA",c.getLabel());
 
134
 
 
135
    }
 
136
}