This commit is contained in:
		
							parent
							
								
									d300b2279c
								
							
						
					
					
						commit
						74fe3c6a58
					
				
					 4 changed files with 27 additions and 20 deletions
				
			
		
							
								
								
									
										16
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								.drone.yml
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -7,9 +7,15 @@ steps:
 | 
			
		|||
  commands:
 | 
			
		||||
  - mdl .
 | 
			
		||||
 | 
			
		||||
- name: python lint
 | 
			
		||||
  image: cytopia/pylint
 | 
			
		||||
 | 
			
		||||
- name: python lint with ruff
 | 
			
		||||
  image: pipelinecomponents/ruff
 | 
			
		||||
  commands:
 | 
			
		||||
  - apk add --no-cache py3-pip
 | 
			
		||||
  - pip3 install -r requirements.txt
 | 
			
		||||
  - find . -type f -name "*.py" | xargs pylint
 | 
			
		||||
  - ruff py_hypercube.py
 | 
			
		||||
 | 
			
		||||
#- name: python lint
 | 
			
		||||
#  image: cytopia/pylint
 | 
			
		||||
#  commands:
 | 
			
		||||
#  - apk add --no-cache py3-pip
 | 
			
		||||
#  - pip3 install -r requirements.txt || true
 | 
			
		||||
#  - find . -type f -name "*.py" | xargs pylint
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								.ruff.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.ruff.toml
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
[lint]
 | 
			
		||||
ignore = ["F403", "F405"]
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
# py_hypercube
 | 
			
		||||
 | 
			
		||||
Conversion of my old 3D "hello world" that animates the 3D projeciton of an hypercube.
 | 
			
		||||
Conversion of my old 3D "hello world" that animates the 3D projection of an hypercube.
 | 
			
		||||
 | 
			
		||||
With more or less parameters
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										27
									
								
								py_hypercube.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										27
									
								
								py_hypercube.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| 
						 | 
				
			
			@ -1,11 +1,10 @@
 | 
			
		|||
#!/usr/bin/python
 | 
			
		||||
# -*- coding: iso8859-15 -*-
 | 
			
		||||
""" projection variable d'un hypercube"""
 | 
			
		||||
 | 
			
		||||
# pour l'interaction avec le système
 | 
			
		||||
# pour l'interaction avec le système
 | 
			
		||||
# pour sqrt() et pow()
 | 
			
		||||
import math
 | 
			
		||||
# pour les nombres aléatoires
 | 
			
		||||
# pour les nombres aléatoires
 | 
			
		||||
from random import randint
 | 
			
		||||
 | 
			
		||||
import pygame as pg
 | 
			
		||||
| 
						 | 
				
			
			@ -13,11 +12,11 @@ from pygame.locals import *
 | 
			
		|||
 | 
			
		||||
# importe tout ce qui est contenu dans le package OpenGL
 | 
			
		||||
from OpenGL.GL import *
 | 
			
		||||
# GLU première couche au dessus d'OpenGL
 | 
			
		||||
# GLU première couche au dessus d'OpenGL
 | 
			
		||||
from OpenGL.GLU import *
 | 
			
		||||
 | 
			
		||||
# couche supérieure, ressemble à la SDL, permet la gestion simplifiée de la configuration,
 | 
			
		||||
# des entrées (clavier souris) et des fonctions de plus haut niveau
 | 
			
		||||
# couche supérieure, ressemble à la SDL, permet la gestion simplifiée de la configuration,
 | 
			
		||||
# des entrées (clavier souris) et des fonctions de plus haut niveau
 | 
			
		||||
from OpenGL.GLUT import *
 | 
			
		||||
 | 
			
		||||
##
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +53,7 @@ frepere = 0
 | 
			
		|||
flagsAnim = [1, 1, 1, 1]
 | 
			
		||||
fullscreen = 0
 | 
			
		||||
 | 
			
		||||
## coordonnées
 | 
			
		||||
## coordonnées
 | 
			
		||||
# position
 | 
			
		||||
x = 0.0
 | 
			
		||||
y = 0.0
 | 
			
		||||
| 
						 | 
				
			
			@ -63,10 +62,10 @@ z = 3.0
 | 
			
		|||
cx = 0.0
 | 
			
		||||
cy = 0.0
 | 
			
		||||
cz = 0.0
 | 
			
		||||
# variables pour l'animation sur les coordonnées de l'espace de projection
 | 
			
		||||
# variables pour l'animation sur les coordonnées de l'espace de projection
 | 
			
		||||
# varAnim = [ -100, -33, 33, 100 ]
 | 
			
		||||
 | 
			
		||||
# variables de départ aléatoires
 | 
			
		||||
# variables de départ aléatoires
 | 
			
		||||
varAnim = [randint(-100, 100),
 | 
			
		||||
           randint(-100, 100),
 | 
			
		||||
           randint(-100, 100),
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +77,7 @@ incAnim = [1.0, 1.0, 1.0, 1.0]
 | 
			
		|||
 | 
			
		||||
# fonction d'affichage principale
 | 
			
		||||
def draw():
 | 
			
		||||
    """ fonction d'affichage principale	appelée par GlutMainLoop"""
 | 
			
		||||
    """ fonction d'affichage principale	appelée par GlutMainLoop"""
 | 
			
		||||
    global x, y, z
 | 
			
		||||
    global cx, cy, cz
 | 
			
		||||
    global varAnime
 | 
			
		||||
| 
						 | 
				
			
			@ -86,7 +85,7 @@ def draw():
 | 
			
		|||
    global incAnime
 | 
			
		||||
    global frepere
 | 
			
		||||
 | 
			
		||||
    # couleur par défaut (le fond entre autre)
 | 
			
		||||
    # couleur par défaut (le fond entre autre)
 | 
			
		||||
    glClearColor(0.0, 0.0, 0.0, 0.0)
 | 
			
		||||
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +104,7 @@ def draw():
 | 
			
		|||
 | 
			
		||||
# gestion du clavier
 | 
			
		||||
def keyboard(key):
 | 
			
		||||
    """ gère les touches normales"""
 | 
			
		||||
    """ gère les touches normales"""
 | 
			
		||||
    global frepere
 | 
			
		||||
    global flagsAnim
 | 
			
		||||
    global fullscreen
 | 
			
		||||
| 
						 | 
				
			
			@ -154,7 +153,7 @@ def draw_line(x1, y1, z1, x2, y2, z2):
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
def draw_repere():
 | 
			
		||||
    """ dessine le repère orthogonal"""
 | 
			
		||||
    """ dessine le repère orthogonal"""
 | 
			
		||||
    glBegin(GL_LINES)
 | 
			
		||||
    glColor3f(1.0, 0.0, 0.0)
 | 
			
		||||
    glVertex2i(0, 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +188,7 @@ def draw_hypercube(a1, b1, c1, d1):
 | 
			
		|||
        hz = hp[p * 4 + 2]
 | 
			
		||||
        ht = hp[p * 4 + 3]
 | 
			
		||||
 | 
			
		||||
        # calcul des coordonnées projetées
 | 
			
		||||
        # calcul des coordonnées projetées
 | 
			
		||||
        X.append( ( b * (pow(b, 2) + pow(c, 2) + pow(d, 2)) + pow(a, 2) * b) * hx + (pow(-b, 2) * a - a * (pow(a, 2) + pow(c, 2) + pow(d, 2))) * hy + (d * (pow(a, 2) + pow(b, 2) + pow(d, 2)) + pow(c, 2) * d) * hz + (c * pow(d, 2) + c * (pow(a, 2) + pow(b, 2) + pow(c, 2))) * ht)
 | 
			
		||||
 | 
			
		||||
        Y.append( (c * (pow(b, 2) + pow(c, 2) + pow(d, 2)) + pow(a, 2) * c) * hx + (-d * (pow(a, 2) + pow(c, 2) + pow(d, 2) ) - pow(b, 2) * d) * hy + (pow(-c, 2) * a-a*(pow(a, 2) + pow(b, 2) + pow(d, 2))) * hz + (-b * pow(d, 2) - b * (pow(a, 2) + pow(b, 2) + pow(c, 2))) * ht)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue