Example #1
0
		/// <summary>
		/// Traslazione
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <returns></returns>
		public static Transform2D Traslazione(double x, double y)
			{
			Transform2D tr = new Transform2D();
			tr.Set(0,2,x);
			tr.Set(1,2,y);
			return tr;
			}
Example #2
0
		/// <summary>
		/// Restituisce trasformazione di scala
		/// </summary>
		/// <param name="sx"></param>
		/// <param name="sy"></param>
		/// <returns></returns>
		public static Transform2D Scala(double sx, double sy)
			{
			Transform2D tr = new Transform2D();
			tr.Set(0,0,sx);
			tr.Set(1,1,sy);
			return tr;			
			}
Example #3
0
		/// <summary>
		/// Rotazione attorno all'origine
		/// </summary>
		/// <param name="alf"></param>
		/// <param name="radianti"></param>
		/// <returns></returns>
		public static Transform2D Rotazione(double alf, bool radianti = true)
			{
			Transform2D tr = new Transform2D();
			if(radianti == false)
				alf = alf * Math.PI/180.0;
			double cosalf = Math.Cos(alf);
			double sinalf = Math.Sin(alf);
			tr.Set(0,0,cosalf);
			tr.Set(1,1,cosalf);
			tr.Set(0,1,-sinalf);
			tr.Set(1,0,sinalf);
			return tr;
			}
Example #4
0
		/// <summary>
		/// Crea corpo ottico dalla lente nella posizione standard
		/// </summary>
		/// <returns></returns>
		//public CorpoOttico CreaCorpoOttico() 
		//    {
		//    #warning Creare funzione CreaCorpoOttivo(Transform2D)
		//    CorpoOttico co = null;
		//    if(this.IsValid)
		//        {
		//        Point2D pt1 = new Point2D(0, RL);						// Punti caratteristici
		//        Point2D pt2 = new Point2D(-ET, RL);
		//        Point2D pt3 = new Point2D(-ET, -RL);
		//        Point2D pt4 = new Point2D(0.0, -RL);
		//        Point2D ct1 = new Point2D(XCC1,0.0);
		//        Point2D ct2 = new Point2D(XCC2,0.0);

		//        Tratto sup1, sup2;											// Contorni
		//        Tratto bordo1, bordo2;
		//        if(TIPO1 == Lente.TipoSuperficie.piana)
		//            sup1 = new Line2D(pt2,pt3);
		//        else if(TIPO1 == Lente.TipoSuperficie.convessa)
		//            sup1 = new Arc2D(pt2,pt3,ct1,Arc2D.TrePunti.Estremi_e_Centro);
		//        else
		//            sup1 = new Arc2D(pt3,pt2,ct1,Arc2D.TrePunti.Estremi_e_Centro);
		//        if(TIPO2 == Lente.TipoSuperficie.piana)
		//            sup2 = new Line2D(pt1,pt4);
		//        else if(TIPO2 == Lente.TipoSuperficie.convessa)
		//            sup2 = new Arc2D(pt4,pt1,ct2,Arc2D.TrePunti.Estremi_e_Centro);
		//        else
		//            sup2 = new Arc2D(pt1,pt4,ct2,Arc2D.TrePunti.Estremi_e_Centro);
		//        bordo1 = new Line2D(pt1, pt2);
		//        bordo2 = new Line2D(pt3,pt4);

		//        string nome_materiale = GetNomeMateriale();									// Imposta i nomi
		//        string nome_lente = GetNomeCorpoOttico();
		//        MaterialeOttico mat_lente = new MaterialeOttico(nome_materiale, this.N);	// Crea il materiale
		//        co = new CorpoOttico(mat_lente,nome_lente);									// Crea il corpo ottico
		//        co.Add(new Contorno(bordo1, StatoSuperficie.Opaca));						// Aggiunge i contorni
		//        co.Add(new Contorno(sup1));
		//        co.Add(new Contorno(bordo2, StatoSuperficie.Opaca));
		//        co.Add(new Contorno(sup2));

		//        }			
		//    return co;
		//    }
		public CorpoOttico CreaCorpoOttico(Transform2D tr = null) 
			{
			CorpoOttico co = null;
			if(this.IsValid)
				{
				if(tr==null)
					{
					tr = new Transform2D(Matrix.Id(Transform2D.Dim2Dhom));
					}
				Point2D pt1 = tr.Transform(new Point2D(0, RL));				// Punti caratteristici
				Point2D pt2 = tr.Transform(new Point2D(-ET, RL));
				Point2D pt3 = tr.Transform(new Point2D(-ET, -RL));
				Point2D pt4 = tr.Transform(new Point2D(0.0, -RL));
				Point2D ct1 = tr.Transform(new Point2D(XCC1,0.0));
				Point2D ct2 = tr.Transform(new Point2D(XCC2,0.0));
				Tratto sup1, sup2;											// Contorni
				Tratto bordo1, bordo2;
				if(TIPO1 == Lente.TipoSuperficie.piana)
					sup1 = new Line2D(pt2,pt3);
				else if(TIPO1 == Lente.TipoSuperficie.convessa)
					sup1 = new Arc2D(pt2,pt3,ct1,Arc2D.TrePunti.Estremi_e_Centro);
				else
					sup1 = new Arc2D(pt3,pt2,ct1,Arc2D.TrePunti.Estremi_e_Centro);
				if(TIPO2 == Lente.TipoSuperficie.piana)
					sup2 = new Line2D(pt1,pt4);
				else if(TIPO2 == Lente.TipoSuperficie.convessa)
					sup2 = new Arc2D(pt4,pt1,ct2,Arc2D.TrePunti.Estremi_e_Centro);
				else
					sup2 = new Arc2D(pt1,pt4,ct2,Arc2D.TrePunti.Estremi_e_Centro);
				bordo1 = new Line2D(pt1, pt2);
				bordo2 = new Line2D(pt3,pt4);

				string nome_materiale = GetNomeMateriale();									// Imposta i nomi
				string nome_lente = GetNomeCorpoOttico();
				MaterialeOttico mat_lente = new MaterialeOttico(nome_materiale, this.N);	// Crea il materiale
				co = new CorpoOttico(mat_lente,nome_lente);									// Crea il corpo ottico
				co.Add(new Contorno(bordo1, StatoSuperficie.Opaca));						// Aggiunge i contorni
				co.Add(new Contorno(sup1));
				co.Add(new Contorno(bordo2, StatoSuperficie.Opaca));
				co.Add(new Contorno(sup2));

				}			
			return co;
			}