summaryrefslogtreecommitdiff
path: root/SimpleRadar_etudiants/CautrMath.cs
blob: 2d5b66e1b85b80ed5607fa7775aa144e6e51c60c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace SimpleRadar
{
    public class MathCautra
    {
        /// CRadarGeo message handlers
        static double PI = 3.1415926535;

        /* conversion degres_radian */
        static double degres_radian = PI / 180.0;

        /* translation coordonees Cautra 3 Cautra 4 */
        //static int translationC3 = 4096;

        /* Transformation LAMBERT */
        static double sin_lt = Math.Sin(47.0 * degres_radian);
        /* sinus de la latitude de tangeance */
        static double inv_sin_lt = 1.0 / sin_lt;

        /* rayon LAMBERT a l'equateur */
        static double re = 6327.721;
        /* rayon LAMBERT au 47 N */
        static double rt = 3201.39922;

        /// <summary>
        ///  Convertion de coordonnees lat,long en  1/8 nm Cautra4
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public static PointF ToCautra4(double latitude, double longitude)
        {
            double a0;                                /* Angle de convergence */
            double r0;                                /* rayon LAMBERT */
            double sin_a0, cos_a0;
            double xx;

            a0 = longitude * sin_lt * degres_radian;
            xx = Math.Tan(PI / 4 - (latitude * degres_radian) / 2.0);
            r0 = re * Math.Pow(xx, sin_lt);
            sin_a0 = Math.Sin(a0);
            cos_a0 = Math.Cos(a0);
            return new PointF(
                    (float)(8.0 * r0 * sin_a0),
                    (float)(8.0 * (rt - (r0 * cos_a0))));
        }
    }
}