2
GeoGebra - Dynamic Mathematics for Everyone
3
http://www.geogebra.org
5
This file is part of GeoGebra.
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.
14
* AlgoEllipseFociPoint.java
16
* Ellipse with Foci A and B passing through point C
20
* adapted from EllipseFociLength
23
package geogebra.kernel;
30
public class AlgoEllipseFociPoint extends AlgoElement {
35
private static final long serialVersionUID = 1L;
36
private GeoPoint A, B, C; // input
37
private GeoConic ellipse; // output
46
ellipse.setLabel(label);
49
public AlgoEllipseFociPoint(
58
ellipse = new GeoConic(cons);
59
setInputOutput(); // for AlgoElement
64
protected String getClassName() {
65
return "AlgoEllipseFociPoint";
69
protected void setInputOutput() {
70
input = new GeoElement[3];
75
output = new GeoElement[1];
77
setDependencies(); // done by AlgoElement
80
public GeoConic getEllipse() {
83
GeoPoint getFocus1() {
86
GeoPoint getFocus2() {
90
// compute ellipse with foci A, B passing through C
91
protected final void compute() {
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);
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]));
103
ellipse.setEllipseHyperbola(A, B, length/2);
106
final public String toString() {
107
StringBuffer sb = new StringBuffer();
109
sb.append(app.getPlain("EllipseWithFociABPassingThroughC",A.getLabel(),B.getLabel(),C.getLabel()));
111
return sb.toString();
2
GeoGebra - Dynamic Mathematics for Everyone
3
http://www.geogebra.org
5
This file is part of GeoGebra.
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.
14
* AlgoEllipseFociPoint.java
16
* Ellipse with Foci A and B passing through point C
20
* adapted from EllipseFociLength
23
package geogebra.kernel;
25
import geogebra.euclidian.EuclidianConstants;
32
public class AlgoEllipseFociPoint extends AlgoElement {
37
private static final long serialVersionUID = 1L;
38
private GeoPoint A, B, C; // input
39
private GeoConic ellipse; // output
48
ellipse.setLabel(label);
51
public AlgoEllipseFociPoint(
60
ellipse = new GeoConic(cons);
61
setInputOutput(); // for AlgoElement
66
public String getClassName() {
67
return "AlgoEllipseFociPoint";
70
public int getRelatedModeID() {
71
return EuclidianConstants.MODE_ELLIPSE_THREE_POINTS;
76
protected void setInputOutput() {
77
input = new GeoElement[3];
82
output = new GeoElement[1];
84
setDependencies(); // done by AlgoElement
87
public GeoConic getEllipse() {
90
GeoPoint getFocus1() {
93
GeoPoint getFocus2() {
97
// compute ellipse with foci A, B passing through C
98
protected final void compute() {
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);
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]));
110
ellipse.setEllipseHyperbola(A, B, length/2);
113
final public String toString() {
114
return app.getPlain("EllipseWithFociABPassingThroughC",A.getLabel(),B.getLabel(),C.getLabel());