FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC

Développement d'applications avec le langage Panoramic
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  MembresMembres  Connexion  
Derniers sujets
» Editeur EliP 6 : Le Tiny éditeur avec 25 onglets de travail
Déterminer si un point P est à l'intérieur d'un triangle Emptypar papydall Hier à 16:57

» PANORAMIC V 1
Déterminer si un point P est à l'intérieur d'un triangle Emptypar papydall Hier à 3:22

» select intégrés [résolu]
Déterminer si un point P est à l'intérieur d'un triangle Emptypar jjn4 Mer 8 Mai 2024 - 17:00

» number_mouse_up
Déterminer si un point P est à l'intérieur d'un triangle Emptypar jjn4 Mer 8 Mai 2024 - 11:59

» Aide de PANORAMIC
Déterminer si un point P est à l'intérieur d'un triangle Emptypar jjn4 Mer 8 Mai 2024 - 11:16

» trop de fichiers en cours
Déterminer si un point P est à l'intérieur d'un triangle Emptypar lepetitmarocain Mer 8 Mai 2024 - 10:43

» Je teste PANORAMIC V 1 beta 1
Déterminer si un point P est à l'intérieur d'un triangle Emptypar papydall Mer 8 Mai 2024 - 4:17

» bouton dans autre form que 0
Déterminer si un point P est à l'intérieur d'un triangle Emptypar leclode Lun 6 Mai 2024 - 13:59

» KGF_dll - nouvelles versions
Déterminer si un point P est à l'intérieur d'un triangle Emptypar Klaus Lun 6 Mai 2024 - 11:41

» Gestion d'un système client-serveur.
Déterminer si un point P est à l'intérieur d'un triangle Emptypar Klaus Lun 6 Mai 2024 - 10:23

» @Jack
Déterminer si un point P est à l'intérieur d'un triangle Emptypar Jack Mar 30 Avr 2024 - 20:40

» Une calculatrice en une ligne de programme
Déterminer si un point P est à l'intérieur d'un triangle Emptypar jean_debord Dim 28 Avr 2024 - 8:47

» Form(résolu)
Déterminer si un point P est à l'intérieur d'un triangle Emptypar leclode Sam 27 Avr 2024 - 17:59

» Bataille navale SM
Déterminer si un point P est à l'intérieur d'un triangle Emptypar jjn4 Ven 26 Avr 2024 - 17:39

» Les maths du crocodile
Déterminer si un point P est à l'intérieur d'un triangle Emptypar jean_debord Jeu 25 Avr 2024 - 10:37

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Mai 2024
LunMarMerJeuVenSamDim
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendrierCalendrier
Le deal à ne pas rater :
Jeux, jouets et Lego : le deuxième à -50% (large sélection)
Voir le deal

 

 Déterminer si un point P est à l'intérieur d'un triangle

Aller en bas 
2 participants
AuteurMessage
papydall

papydall


Nombre de messages : 7008
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

Déterminer si un point P est à l'intérieur d'un triangle Empty
MessageSujet: Déterminer si un point P est à l'intérieur d'un triangle   Déterminer si un point P est à l'intérieur d'un triangle EmptyJeu 20 Oct 2022 - 5:23

Mon premier programme après avoir tout perdu Sad

En fait, rien de spécial!
C'est une fonction qui détermine si un point P(x,y) est à l'intérieur ou à l'extérieur d'un triangle défini pa trois points A, B , C

Code:

rem ============================================================================
rem            Mon premier programme après avoir tout perdu
rem                    Point_Dans_Triangle.bas
rem ============================================================================
rem Il s’agit d’écrire une fonction FNC qui détermine si le point P(x,y) est
rem à l’intérieur ou à l’extérieur du triangle défini par 3 points A, B et C
rem ============================================================================

dim Px,Py : ' coordonnées du point P
dim Ax,Ay,Bx,By,Cx,Cy : ' coordonnées des trois points A, B et C
dim x,y,i
color 0,0,0,0
caption 0,"Les points rouges sont à l'intérieur du triangle; les jaunes à l'extérieur"
for i = 1 to 10
    ' Trois points au hazard définissant le triangle
    Ax = int(rnd(200)+60)  : Ay = int(rnd(355)+25)
    Bx = int(rnd(100)+130) : By = int(rnd(350)+35)
    Cx = int(rnd(430)+55)  : Cy = int(rnd(230)+30)
    ' Dessiner le triangle
    cls : 2d_pen_color 255,255,255 : 2d_poly_from Ax,Ay
    2d_poly_to Bx,By : 2d_poly_to Cx,Cy : 2d_poly_to Ax,Ay
    ' Le point P
    for x = 50 to 500 step 10
        for y = 20 to 400 step 10
            Px = x : Py = y
            if Point_Dans_Triangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py) = 1
               2d_pen_color 255,0,0 : 2d_point Px,Py : 2d_circle Px,Py,1
            else
               2d_pen_color 255,255,0 : 2d_point Px,Py : 2d_circle Px,Py,1
            end_if
        next y
    next x
    pause 2000
next i
          
end
rem ============================================================================
' On utilise les coordonnées du barycentre pour déterminer si le point est à
' l'intérieur
' La fonction retourne 1 si le point P est à l'intérieur; retourne 0 sinon
FNC Point_Dans_Triangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)
    dim_local a,s,t
    a = 0-By*Cx + Ay*(Cx-Bx) + Ax*(By-Cy) + Bx*Cy
    s = ( Ay*Cx - Ax*Cy + (Cy-Ay)*Px + (Ax-Cx)*Py) / a
    t = ( Ax*By - Ay*Bx + (Ay-By)*Px + (Bx-Ax)*Py) / a
    if (s <= 0) or (t <= 0) or ((s+t) >= 1)  
       result 0  
    else
       result 1
    end_if
END_FNC
rem ============================================================================
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Marc

Marc


Nombre de messages : 2392
Age : 63
Localisation : TOURS (37)
Date d'inscription : 17/03/2014

Déterminer si un point P est à l'intérieur d'un triangle Empty
MessageSujet: Re: Déterminer si un point P est à l'intérieur d'un triangle   Déterminer si un point P est à l'intérieur d'un triangle EmptySam 22 Oct 2022 - 10:22

Merci du partage Papydall !

Comme toujours, ton code est clair, net et bien commenté.
C'est un régal à lire, c'est du Papydall !


Revenir en haut Aller en bas
 
Déterminer si un point P est à l'intérieur d'un triangle
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Déterminer la quantité de RAM.
» Un triangle celtique
» Les Bolygones
» Le triangle de Penrose
» Triangle à coins arrondis

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC :: PANORAMIC :: Vos sources, vos utilitaires à partager-
Sauter vers: