public IHttpActionResult PutRayon(int id, Rayon rayon)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rayon.IdRayon)
            {
                return(BadRequest());
            }

            db.Entry(rayon).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RayonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
    //fonction qui permet de récupéré l'intersection entre un rayon et un segment
    private Intersection GetIntersection(Rayon ray, Segment seg)
    {
        Intersection intersection = new Intersection(Vector2.zero, -1);

        Vector2 sdir = seg.direction - seg.origin;
        //on calcule la magnétude du rayon et du segment afin de pouvoir déterminé si ils sont parallèles
        float r_mag = Mathf.Sqrt(ray.direction.x * ray.direction.x + ray.direction.y * ray.direction.y);
        float s_mag = Mathf.Sqrt(sdir.x * sdir.x + sdir.y * sdir.y);

        if (ray.direction.x / r_mag == sdir.x / s_mag && ray.direction.y / r_mag == sdir.y / s_mag)
        {
            return(intersection);
        }

        //on calcule la solution du système d'équation entre celle du rayon et celle du segment
        float T2 = (ray.direction.x * (seg.origin.y - ray.origin.y) + ray.direction.y * (ray.origin.x - seg.origin.x)) / ((sdir.x * ray.direction.y) - (sdir.y * ray.direction.x));
        float T1 = (seg.origin.x + sdir.x * T2 - ray.origin.x) / ray.direction.x;

        // si celle ci est négative (donc innexcistante) ou que T2 (la solution pour le segment) n'est pas dans le segment, on stope la fonction
        if (T1 < 0)
        {
            return(intersection);
        }
        if (T2 < -0.0001f || T2 > 1.0001f)
        {
            return(intersection);
        }

        //on retourne le point d'intersection
        intersection       = new Intersection();
        intersection.pts   = ray.origin + (ray.direction * T1);
        intersection.param = T1;
        return(intersection);
    }
Beispiel #3
0
        /// <summary>
        /// Obtient le voisinage du gagnant
        /// </summary>
        /// <param name="gagnant"></param>
        /// <param name="totalIteration"></param>
        /// <param name="iterationCourante"></param>
        /// <returns>
        /// Le gagnant n'est pas dans la liste retournée
        /// </returns>
        protected List <RobotNeurone> Voisinage(RobotNeurone gagnant, int totalIteration, int iterationCourante)
        {
            // on commence par calculer le rayon
            // on le fait varier exponentiellement de 32 à 6
            int    min  = 6;
            int    max  = 32;
            double beta = -1 * totalIteration / Math.Log((double)(min) / max);

            Rayon = (int)(max * Math.Exp(-1 * iterationCourante / beta));

            Debug.WriteLine("Rayon: " + Rayon.ToString() + ", Itération: " + iterationCourante.ToString());

            // on recherche les neurones présents dans le rayon
            // leurs poids seront ajustés
            List <RobotNeurone> voisinage = new List <RobotNeurone>();

            for (int x = 0; x < Line.Length; x++)
            {
                if (Math.Abs(x - gagnant.X) < Rayon)
                {
                    RobotNeurone neurone = Line[x];
                    neurone.Distance = Distance(neurone, gagnant);

                    voisinage.Add(neurone);
                }
            }

            Debug.WriteLine("Voisinage: " + voisinage.Count.ToString());
            return(voisinage);
        }
        public ActionResult Create(RayonM RayonM, HttpPostedFileBase Image)
        {
            if (!ModelState.IsValid || Image == null || Image.ContentLength == 0)
            {
                RedirectToAction("Create");
            }
            Rayon r = new Rayon()
            {
                IdRayon = RayonM.IdRayon,
                imageR  = Image.FileName,
                //imageR = RayonM.imageR,
                typeR       = RayonM.typeR,
                description = RayonM.description,
                flag        = RayonM.flag
            };

            Service.Add(r);
            Service.Commit();

            var path = Path.Combine(Server.MapPath("~/Content/Uploads/"), Image.FileName);

            Image.SaveAs(path);

            return(RedirectToAction("Index"));
        }
Beispiel #5
0
    //le but de cette fonction est de déterminé l'ensemble des rayons qui vont être projetté sur les segments
    private void GetRays()
    {
        m_lsRays = new List <Rayon>();
        Rayon ray;

        foreach (Segment seg in m_lsSegments)
        {
            ray = new Rayon(transform.position, seg.origin - (Vector2)transform.position);
            defineRay(ray);
        }

        if (m_lsSegments.Count > 0)
        {
            ray = new Rayon(transform.position, m_lsSegments[m_lsSegments.Count - 1].direction - (Vector2)transform.position);
            defineRay(ray);
        }

        foreach (Segment seg in m_lsNonStaticSegment)
        {
            ray = new Rayon(transform.position, seg.origin - (Vector2)transform.position);
            defineRay(ray);
        }

        if (m_lsNonStaticSegment.Count > 0)
        {
            ray = new Rayon(transform.position, m_lsNonStaticSegment[m_lsNonStaticSegment.Count - 1].direction - (Vector2)transform.position);
            defineRay(ray);
        }
    }
Beispiel #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Rayon rayon = db.Rayon.Find(id);

            db.Rayon.Remove(rayon);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            Rayon rayon = Service.GetById((int)id);

            Service.Delete(rayon);
            Service.Commit();
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
    //le but de cette fonction est de déterminé l'ensemble des rayons qui vont être projetté sur les segments
    private void GetRays()
    {
        float angle;

        m_lsRays = new List <Rayon>();
        Rayon   ray;
        Vector2 vec = new Vector2(Mathf.Cos((orientation - opening) * Mathf.Deg2Rad), Mathf.Sin((orientation - opening) * Mathf.Deg2Rad));

        foreach (Segment seg in m_lsSegments)
        {
            ray   = new Rayon(transform.position, seg.origin - (Vector2)transform.position);
            angle = (Vector2.SignedAngle(vec, ray.direction));

            if (angle <= opening * 2 && angle >= 0)
            {
                defineRay(ray);
            }
        }

        if (m_lsSegments.Count > 0)
        {
            ray   = new Rayon(transform.position, m_lsSegments[m_lsSegments.Count - 1].direction - (Vector2)transform.position);
            angle = (Vector2.SignedAngle(vec, ray.direction));

            if (angle <= opening * 2 && angle >= 0)
            {
                defineRay(ray);
            }
        }

        foreach (Segment seg in m_lsNonStaticSegment)
        {
            ray   = new Rayon(transform.position, seg.origin - (Vector2)transform.position);
            angle = (Vector2.SignedAngle(vec, ray.direction));

            if (angle <= opening * 2 && angle >= 0)
            {
                defineRay(ray);
            }
        }

        if (m_lsNonStaticSegment.Count > 0)
        {
            ray   = new Rayon(transform.position, m_lsNonStaticSegment[m_lsNonStaticSegment.Count - 1].direction - (Vector2)transform.position);
            angle = (Vector2.SignedAngle(vec, ray.direction));

            if (angle <= opening * 2 && angle >= 0)
            {
                defineRay(ray);
            }
        }

        ray = new Rayon(transform.position, new Vector2(Mathf.Cos((opening + orientation) * Mathf.Deg2Rad), Mathf.Sin((opening + orientation) * Mathf.Deg2Rad)));
        defineRay(ray);

        ray = new Rayon(transform.position, new Vector2(Mathf.Cos((-opening + orientation) * Mathf.Deg2Rad), Mathf.Sin((-opening + orientation) * Mathf.Deg2Rad)));
        defineRay(ray);
    }
Beispiel #9
0
 public ActionResult Edit([Bind(Include = "id_rayon,code_rayon")] Rayon rayon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rayon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rayon));
 }
Beispiel #10
0
        public ActionResult Create([Bind(Include = "id_rayon,code_rayon")] Rayon rayon)
        {
            if (ModelState.IsValid)
            {
                db.Rayon.Add(rayon);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rayon));
        }
        public IHttpActionResult GetRayon(int id)
        {
            Rayon rayon = db.Rayons.Find(id);

            if (rayon == null)
            {
                return(NotFound());
            }

            return(Ok(rayon));
        }
        public IHttpActionResult PostRayon(Rayon rayon)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Rayons.Add(rayon);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = rayon.IdRayon }, rayon));
        }
        // GET: Rayon/Delete/5
        public ActionResult Delete(int id)
        {
            Rayon  rayon = new Rayon();
            RayonM r     = new RayonM();

            rayon         = Service.GetById((int)id);
            r.IdRayon     = rayon.IdRayon;
            r.imageR      = rayon.imageR;
            r.typeR       = rayon.typeR;
            r.description = rayon.description;
            r.flag        = rayon.flag;
            return(View(r));
        }
Beispiel #14
0
        private void btnAjouter_Click(object sender, RoutedEventArgs e)
        {
            if (cboEmployes.SelectedItem != null)
            {
                if (cboRayons.SelectedItem != null)
                {
                    Employe selectedEmploye = (cboEmployes.SelectedItem as Employe);
                    Rayon   selectedRayon   = (cboRayons.SelectedItem as Rayon);

                    //lstTravailsRayons.SelectedItem as Travailler).Date.ToString() 25/03/2016 12:00:51
                    //(lstTravailsRayons.SelectedItem as Travailler).Date.ToShortDateString() c'est de type DateTime , on convertit en short string 25/03/2016
                    //lstTravailsRayons.SelectedItem as Travailler).Date.ToString("yyyy-MM-dd")  la date à string avec un format
                    //MessageBox.Show((lstTravailsRayons.SelectedItem as Travailler).Date.ToString("yyyy-MM-dd")); 2016-03-25

                    // DateTime object
                    //DateTime test = new DateTime(2015, 01, 01);
                    //test.ToString("yyyy-MM-dd");

                    // Date aujourd'hui
                    // DateTime date = DateTime.Now; // Now propriété donne un objet de type Datetime avec la date d'aujourd'hui
                    //MessageBox.Show(date.ToString("yyyy-MM-dd")); // 2020-11-13
                    // gstBdd.ajouterTravailler(selectedEmploye, selectedRayon, date.ToString("yyyy-MM-dd"), Convert.ToInt16(txtValSld.Text));

                    // Datepicker
                    //MessageBox.Show(dpTravil.SelectedDate.ToString()); 25/03/2016 00:00:00
                    //MessageBox.Show(dpTravil.SelectedDate.Value.ToString("yyyy-MM-dd")); // format


                    // facultatif la datePicker
                    if (dpTravil.SelectedDate.HasValue)
                    {
                        gstBdd.ajouterTravailler(selectedEmploye, selectedRayon, dpTravil.SelectedDate.Value.ToString("yyyy-MM-dd"), Convert.ToInt16(txtValSld.Text));
                        lstTravailsRayons.ItemsSource = null;
                        lstTravailsRayons.ItemsSource = gstBdd.GetAllDetailsTravailDEmploye((cboEmployes.SelectedItem as Employe).NumEmploye);
                    }
                    else
                    {
                        MessageBox.Show("Veuillez choisir une date", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Veuillez choisir un rayon", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Veuillez choisir un employé", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #15
0
        // GET: Rayon/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Rayon rayon = db.Rayon.Find(id);

            if (rayon == null)
            {
                return(HttpNotFound());
            }
            return(View(rayon));
        }
        public IHttpActionResult DeleteRayon(int id)
        {
            Rayon rayon = db.Rayons.Find(id);

            if (rayon == null)
            {
                return(NotFound());
            }

            db.Rayons.Remove(rayon);
            db.SaveChanges();

            return(Ok(rayon));
        }
Beispiel #17
0
 //une fonction afin de définir trois rayon avec un décalage très faible pour pouvoir avoir des rayons qui ne s'arréte pas au premier points
 private void defineRay(Rayon ray)
 {
     //on ajoute le rayon de base
     m_lsRays.Add(ray);
     //décalage de +0.001 degré
     m_lsRays.Add(new Rayon(transform.position, new Vector2(
                                ray.direction.x - ray.direction.y * 0.001f,
                                ray.direction.x * 0.001f + ray.direction.y
                                )));
     //décalage de -0.001 degré
     m_lsRays.Add(new Rayon(transform.position, new Vector2(
                                ray.direction.x - ray.direction.y * -0.001f,
                                ray.direction.x * -0.001f + ray.direction.y
                                )));
 }
        // GET: Rayon/Details/5
        public ActionResult Details(int?id)
        {
            Rayon  rayon = new Rayon();
            RayonM r     = new RayonM();

            rayon = Service.GetById((int)id);
            int idr = rayon.IdRayon;

            r.IdRayon     = rayon.IdRayon;
            r.imageR      = rayon.imageR;
            r.typeR       = rayon.typeR;
            r.description = rayon.description;
            r.flag        = rayon.flag;
            //var productss = ServiceProduct.GetMany();
            //productss = productss.Where(p => p.IdRayon == idr);
            //r.products = productss;
            return(View(r));
        }
Beispiel #19
0
        public async Task <IActionResult> Edit(Rayon model)
        {
            model.UserId = (await userManager.FindByNameAsync(User.Identity.Name)).Id;

            context.Entry(model).State = EntityState.Modified;
            try
            {
                await context.SaveChangesAsync();

                TempData["success"] = $"{entity} güncelleme işlemi başarıyla tamamlanmıştır.";
                return(RedirectToAction("Index"));
            }
            catch (DbUpdateException)
            {
                TempData["error"] = $"Aynı isimli birden fazla {entity.ToLower()} olamaz.";
                return(View(model));
            }
        }
        public ActionResult DetailsClient(int?id)
        {
            Rayon  rayon = new Rayon();
            RayonM r     = new RayonM();

            rayon         = Service.GetById((int)id);
            r.IdRayon     = rayon.IdRayon;
            r.imageR      = rayon.imageR;
            r.typeR       = rayon.typeR;
            r.description = rayon.description;
            r.flag        = rayon.flag;
            //r.products = rayon.products;
            List <Product> Products = ServiceProduct.GetMany().ToList();

            Products = Products.Where(p => p.IdRayon == id).ToList();
            //Products = Products.GroupBy(p => p.CategorieP);
            ViewBag.MyProducts = new SelectList(Products, "IdProduct", "CategorieP");
            return(View(r));
        }
Beispiel #21
0
        public async Task <IActionResult> Create(Rayon model)
        {
            model.Date   = DateTime.Now;
            model.UserId = (await userManager.FindByNameAsync(User.Identity.Name)).Id;

            var lastOrder = context.Rayons.OrderByDescending(p => p.SortOrder).FirstOrDefault()?.SortOrder ?? 0;

            model.SortOrder = lastOrder + 1;

            context.Entry(model).State = EntityState.Added;
            try
            {
                await context.SaveChangesAsync();

                TempData["success"] = $"{entity} ekleme işlemi başarıyla tamamlanmıştır.";
                return(RedirectToAction("Index"));
            }
            catch (DbUpdateException)
            {
                TempData["error"] = $"Aynı isimli birden fazla {entity.ToLower()} olamaz.";
                return(View(model));
            }
        }
 private void cboRayons_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     leRayon = new Rayon((cboRayons.SelectedItem as Rayon).NumR, (cboRayons.SelectedItem as Rayon).NomR);
 }