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

« back to all changes in this revision

Viewing changes to geogebra/kernel/AlgoEllipseFociPoint.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
 
 * AlgoEllipseFociPoint.java
15
 
 * 
16
 
 * Ellipse with Foci A and B passing through point C
17
 
 *
18
 
 * Michael Borcherds
19
 
 * 2008-04-06
20
 
 * adapted from EllipseFociLength
21
 
 */
22
 
 
23
 
package geogebra.kernel;
24
 
 
25
 
/**
26
 
 *
27
 
 * @author  Markus
28
 
 * @version 
29
 
 */
30
 
public class AlgoEllipseFociPoint extends AlgoElement {
31
 
 
32
 
    /**
33
 
         * 
34
 
         */
35
 
        private static final long serialVersionUID = 1L;
36
 
        private GeoPoint A, B, C; // input    
37
 
    private GeoConic ellipse; // output             
38
 
 
39
 
    AlgoEllipseFociPoint(
40
 
            Construction cons,
41
 
            String label,
42
 
            GeoPoint A,
43
 
            GeoPoint B,
44
 
            GeoPoint C) {
45
 
                this(cons, A, B, C);
46
 
            ellipse.setLabel(label);
47
 
        }
48
 
 
49
 
    public AlgoEllipseFociPoint(
50
 
            Construction cons,
51
 
            GeoPoint A,
52
 
            GeoPoint B,
53
 
            GeoPoint C) {
54
 
            super(cons);
55
 
            this.A = A;
56
 
            this.B = B;
57
 
            this.C = C;
58
 
            ellipse = new GeoConic(cons);
59
 
            setInputOutput(); // for AlgoElement
60
 
 
61
 
            compute();
62
 
        }
63
 
 
64
 
    protected String getClassName() {
65
 
        return "AlgoEllipseFociPoint";
66
 
    }
67
 
 
68
 
    // for AlgoElement
69
 
    protected void setInputOutput() {
70
 
        input = new GeoElement[3];
71
 
        input[0] = A;
72
 
        input[1] = B;
73
 
        input[2] = C;
74
 
 
75
 
        output = new GeoElement[1];
76
 
        output[0] = ellipse;
77
 
        setDependencies(); // done by AlgoElement
78
 
    }
79
 
 
80
 
    public GeoConic getEllipse() {
81
 
        return ellipse;
82
 
    }
83
 
    GeoPoint getFocus1() {
84
 
        return A;
85
 
    }
86
 
    GeoPoint getFocus2() {
87
 
        return B;
88
 
    }
89
 
 
90
 
    // compute ellipse with foci A, B passing through C
91
 
    protected final void compute() {
92
 
        
93
 
                double xyA[] = new double[2];
94
 
                double xyB[] = new double[2];
95
 
                double xyC[] = new double[2];
96
 
                A.getInhomCoords(xyA);
97
 
                B.getInhomCoords(xyB);
98
 
                C.getInhomCoords(xyC);
99
 
                
100
 
                double length = Math.sqrt((xyA[0]-xyC[0])*(xyA[0]-xyC[0])+(xyA[1]-xyC[1])*(xyA[1]-xyC[1])) +
101
 
                Math.sqrt((xyB[0]-xyC[0])*(xyB[0]-xyC[0])+(xyB[1]-xyC[1])*(xyB[1]-xyC[1]));
102
 
        
103
 
        ellipse.setEllipseHyperbola(A, B, length/2);
104
 
    }
105
 
 
106
 
    final public String toString() {
107
 
        StringBuffer sb = new StringBuffer();
108
 
 
109
 
        sb.append(app.getPlain("EllipseWithFociABPassingThroughC",A.getLabel(),B.getLabel(),C.getLabel()));
110
 
        
111
 
        return sb.toString();
112
 
    }
113
 
}
 
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
 * AlgoEllipseFociPoint.java
 
15
 * 
 
16
 * Ellipse with Foci A and B passing through point C
 
17
 *
 
18
 * Michael Borcherds
 
19
 * 2008-04-06
 
20
 * adapted from EllipseFociLength
 
21
 */
 
22
 
 
23
package geogebra.kernel;
 
24
 
 
25
import geogebra.euclidian.EuclidianConstants;
 
26
 
 
27
/**
 
28
 *
 
29
 * @author  Markus
 
30
 * @version 
 
31
 */
 
32
public class AlgoEllipseFociPoint extends AlgoElement {
 
33
 
 
34
    /**
 
35
         * 
 
36
         */
 
37
        private static final long serialVersionUID = 1L;
 
38
        private GeoPoint A, B, C; // input    
 
39
    private GeoConic ellipse; // output             
 
40
 
 
41
    AlgoEllipseFociPoint(
 
42
            Construction cons,
 
43
            String label,
 
44
            GeoPoint A,
 
45
            GeoPoint B,
 
46
            GeoPoint C) {
 
47
                this(cons, A, B, C);
 
48
            ellipse.setLabel(label);
 
49
        }
 
50
 
 
51
    public AlgoEllipseFociPoint(
 
52
            Construction cons,
 
53
            GeoPoint A,
 
54
            GeoPoint B,
 
55
            GeoPoint C) {
 
56
            super(cons);
 
57
            this.A = A;
 
58
            this.B = B;
 
59
            this.C = C;
 
60
            ellipse = new GeoConic(cons);
 
61
            setInputOutput(); // for AlgoElement
 
62
 
 
63
            compute();
 
64
        }
 
65
 
 
66
    public String getClassName() {
 
67
        return "AlgoEllipseFociPoint";
 
68
    }
 
69
    
 
70
    public int getRelatedModeID() {
 
71
        return EuclidianConstants.MODE_ELLIPSE_THREE_POINTS;
 
72
    }
 
73
    
 
74
 
 
75
    // for AlgoElement
 
76
    protected void setInputOutput() {
 
77
        input = new GeoElement[3];
 
78
        input[0] = A;
 
79
        input[1] = B;
 
80
        input[2] = C;
 
81
 
 
82
        output = new GeoElement[1];
 
83
        output[0] = ellipse;
 
84
        setDependencies(); // done by AlgoElement
 
85
    }
 
86
 
 
87
    public GeoConic getEllipse() {
 
88
        return ellipse;
 
89
    }
 
90
    GeoPoint getFocus1() {
 
91
        return A;
 
92
    }
 
93
    GeoPoint getFocus2() {
 
94
        return B;
 
95
    }
 
96
 
 
97
    // compute ellipse with foci A, B passing through C
 
98
    protected final void compute() {
 
99
        
 
100
                double xyA[] = new double[2];
 
101
                double xyB[] = new double[2];
 
102
                double xyC[] = new double[2];
 
103
                A.getInhomCoords(xyA);
 
104
                B.getInhomCoords(xyB);
 
105
                C.getInhomCoords(xyC);
 
106
                
 
107
                double length = Math.sqrt((xyA[0]-xyC[0])*(xyA[0]-xyC[0])+(xyA[1]-xyC[1])*(xyA[1]-xyC[1])) +
 
108
                Math.sqrt((xyB[0]-xyC[0])*(xyB[0]-xyC[0])+(xyB[1]-xyC[1])*(xyB[1]-xyC[1]));
 
109
        
 
110
        ellipse.setEllipseHyperbola(A, B, length/2);
 
111
    }
 
112
 
 
113
    final public String toString() {
 
114
        return app.getPlain("EllipseWithFociABPassingThroughC",A.getLabel(),B.getLabel(),C.getLabel());
 
115
    }
 
116
}