Salve a tutti,
spero qualcuno possa aiutarmi.
Dovrei trovare il punto di intersezione tra un segmento (un oggetto Retta da me costruito) e una circonferenza.
Nel mio codice ho definito un cerchio così':

codice:
Ellipse2D.Double cerchio=new Double((int)x, (int)y, diametro, diametro);
mentre di seguito posto la mia classe retta. Qualcuno sa dirmi come trovare gli eventuali punti di intersezione? Grazie

codice:
public class Retta {

	/*
	 * Retta.java
	 *
	 * Created on 1 febbraio 2007, 20.13
	 *
	 * To change this template, choose Tools | Template Manager
	 * and open the template in the editor.
	 */

	protected Punto p0;
	
	protected double m;
	/** Costruttore nullo */
	public Retta() {
		//nulla
	}
	// Overloading del costruttore nullo
	public Retta(Punto p0, double m) {
		this.p0=p0;
		this.m=m;
	}
	
	
	.....
	/** Overloading del costruttore precedente: individua la rella
	passante per due punti */
	public Retta(Punto p1, Punto p2) {
		this(p1,(p2.y-p1.y)/(p2.x-p1.x));
		
	}
	/** Overloading del costruttore: individua la retta
	 * di coefficiente angolare c e termine noto t
	 */
	public Retta(double c, double t) {
		this(new Punto(0,t),c);
	}
	/** Stabilisce se il punto p appartiene alla retta */
	public boolean appartiene(Punto p) {
		return (p.y-p0.y==m*(p.x-p0.x));
	}
	/** Verifica se due rette sono uguali */
	public boolean equals(Retta r) {
		return (this.appartiene(r.p0) && this.parallela(r));
	}

	/** Stabilisce il parallelismo tra rette */
	public boolean parallela(Retta r) {
		return (r.m==this.m);
	}
	/** Restituisce il coefficiente angolare della retta */
	public double coefficienteAngolare() {
		return m;
	}
	/** Restituisce il termine noto */
	public double termineNoto() {
		return p0.y-m*p0.x;
	}
	/** Trova il punto di intersezione tra due rette se esiste */
	public Punto intersezione(Retta r) {
		double x=0;
		double y=0;
		if (!this.parallela(r)) {
			x=(this.termineNoto()-r.termineNoto())/(r.coefficienteAngolare()-
					this.coefficienteAngolare());
			y=r.coefficienteAngolare()*x+r.termineNoto();
			
		} 
		
		if(this.isParallelaAsseX()){
			x=(this.termineNoto()-r.termineNoto())/(r.coefficienteAngolare()-
					this.coefficienteAngolare());
			y= this.p0.y;
			
		}
		
		if(this.isParallelaAsseY()){
			x=this.p0.x;
			y= r.coefficienteAngolare()*x+r.termineNoto();
			
		}
		
		if(r.isParallelaAsseX()){
			x=(this.termineNoto()-r.termineNoto())/(r.coefficienteAngolare()-
					this.coefficienteAngolare());
			y= r.p0.y;
			
		}
		
		if(r.isParallelaAsseY()){
			x=r.p0.x;
			y= this.coefficienteAngolare()*x+this.termineNoto();
			
		}
		
		if(this.isParallelaAsseX()&&r.isParallelaAsseY()){
			x=r.p0.x;
			y=this.p0.y;
		}
		
		if(this.isParallelaAsseY()&&r.isParallelaAsseX()){
			x=this.p0.x;
			y=r.p0.y;
		}
		return new Punto(x,y);
		
			
			
	}
	/** Stabilisce se la retta è parallela all'asse delle X */
	public boolean isParallelaAsseX() {
		return (m==0);
	}
	/** Stabilisce se la retta è parallela all'asse delle Y */
	public boolean isParallelaAsseY() {
		return (m==Double.POSITIVE_INFINITY || m==Double.NEGATIVE_INFINITY);
	}
	/** Punto di intersezione con l'asse delle X, se esiste */
	public Punto intersezioneAsseX() {
		if (!this.isParallelaAsseX())
			return new Punto(p0.x-p0.y/m,0);
		else
			return null;
	}
	/** Punto di intersezione con l'asse delle Y, se esiste */
	public Punto intersezioneAsseY() {
		if (!this.isParallelaAsseY())
			return new Punto(0,p0.y-p0.x*m);
		else
			return null;
	}
}