bonjour Frenchy pilou
Je viens d’essayer MOL le logiciel dont tu as mis les images
Et Je n’ai pas trouvé ces commandes dans le menu es ce normal.
Polygones circonscrit ?
Perpendiculaire a tout objet ?
Bissectrices sur tout objet avec une droite ?
Placer une tangente par exemple je n’ai pas trouvé non plus ?
Il faut dire qu’une perpendiculaire qui suit une droite et que l’on accroche sur un l’objet me parait indispensable !
car à l’école on commence par cela en géométrie. lolll
Peut être alors dans la version 2
j'ai aussi trouve ce code demo sympa sur le site Allemand
Code : Tout sélectionner
;####################################
;######## auteur #NULL titre poligone include
;####################################
; polygon.pbi
;XIncludeFile "E:\pbi\getAngle.pbi"
;{ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ E:\pbi\getAngle.pbi
; getAngle.pbi
Procedure.f getAngle(mx,my, Px,py, mode.l=1)
; returns the angle of a line going from point
; [mx,my] to point [px,py] in radian
; mode=1 (default):
; pointing to the right means 0 degrees
; pointing to the top means 90 degrees, ect
; [math y-axis]
; mode=-1:
; pointing to the right means 0 degrees
; pointing to the bottom means 90 degrees, ect
; [screen y-axis.]
Static xd.l, yd.l, Alpha.f
xd=Px-mx
yd=py-my
If xd>0
If yd<0 :: Alpha= ATan(-yd / xd )
ElseIf yd>=0 :: Alpha= 2*#PI - ATan( yd / xd )
EndIf
ElseIf xd<0
If yd<0 :: Alpha= #PI - ATan(-yd /-xd )
ElseIf yd>=0 :: Alpha= #PI + ATan( yd /-xd )
EndIf
ElseIf xd=0
If yd>0 : Alpha= #PI*1.5
ElseIf yd<0 : Alpha= #PI*0.5
EndIf
EndIf
If mode=-1
Alpha = 2*#PI-Alpha
EndIf
; If Not Random(200)
; Debug Str(xd) + " | " + Str(yd) + " | " + StrF(alpha)
; EndIf
ProcedureReturn Alpha
EndProcedure
; [...]
;}
; ________________________________/ [end] E:\pbi\getAngle.pbi
Structure _S_poly
p0.POINT
p.POINT
go.POINT
center.POINT
radius.l
angle.f
Color.l
relative.l
temp.f
EndStructure
Global _poly._S_poly
; 'initPoly(..)' sets the initial coordiantes for a new polygon.
; you can also set a color (default is white)
; set 'relative_' to #FALSE if following calls of 'setPoly(..)'
; use absolute coordinates. if set to #TRUE (default) 'setPoly(..)'
; moves relative to its current position
Macro initPoly(x_, y_, color_=$FFFFFF, relative_=#True)
_poly\p0\x = x_
_poly\p0\y = y_
_poly\p\x = x_
_poly\p\y = y_
_poly\Color = color_
_poly\relative = relative_
_poly\angle = 0
EndMacro
; 'setPoly(..)' sets a new point / adds a segment.
; paramters 'x_'/'y_' are used as absolute (i.e.:screen-coordinates)
; or relaitve to the current position, according to what was defined
; in 'initPoly(..)'
; you can choose a optional color for this segment.
Macro setPoly(x_, y_, color_=_poly\Color)
_poly\go\x = (x_)+(0 Or _poly\relative)*_poly\p\x
_poly\go\y = (y_)+(0 Or _poly\relative)*_poly\p\y
LineXY( _poly\p\x, _poly\p\y, _poly\go\x, _poly\go\y, color_)
_poly\p\x = _poly\go\x
_poly\p\y = _poly\go\y
EndMacro
; 'setPoly2(..)' sets a new point / adds a segment.
; paramter 'a_' is the angle of the segment relative to
; the current angle. 'r_' is the length of the segment
; you can choose an optional color for this segment.
; 'a_' is always relative.
; 'r_' is always absolute
Macro setPolyA(a_, r_, color_=_poly\Color)
_poly\radius = (r_)
_poly\angle + (a_)
Line( _poly\p\x, _poly\p\y, _poly\radius*Cos(_poly\angle), _poly\radius*Sin(_poly\angle), color_)
_poly\p\x + _poly\radius*Cos(_poly\angle)
_poly\p\y + _poly\radius*Sin(_poly\angle)
EndMacro
; 'closePoly()' is not required, but can be used to easily close
; a polygon, that is to say to draw a line from the current postion
; back to the initial position.
; you can choose an optional color for this segment.
Macro closePoly(color_=_poly\Color)
LineXY(_poly\p\x, _poly\p\y, _poly\p0\x, _poly\p0\y, color_)
EndMacro
Macro initRadialPolyA(xCenter_, yCenter_, a_, r_, color_=$FFFFFF, relative_=#True)
_poly\center\x = xCenter_
_poly\center\y = yCenter_
_poly\p0\x = _poly\center\x + (r_) * Cos(a_)
_poly\p0\y = _poly\center\y + (r_) * Sin(a_)
_poly\p\x = _poly\p0\x
_poly\p\y = _poly\p0\y
_poly\Color = color_
_poly\relative = relative_
_poly\angle = a_
EndMacro
Macro setRadialPolyA(a_, r_, color_=_poly\Color)
_poly\angle = (a_) + (0 Or _poly\relative)*_poly\angle
_poly\go\x = _poly\center\x + (r_) * Cos(_poly\angle)
_poly\go\y = _poly\center\y + (r_) * Sin(_poly\angle)
LineXY( _poly\p\x, _poly\p\y, _poly\go\x, _poly\go\y, color_)
_poly\p\x = _poly\go\x
_poly\p\y = _poly\go\y
EndMacro
Macro initRadialPoly(xCenter_, yCenter_, x_, y_, a_, color_=$FFFFFF, relative_=#True)
_poly\center\x = xCenter_
_poly\center\y = yCenter_
_poly\angle = a_
_poly\temp = getAngle(_poly\center\x, _poly\center\y, _poly\center\x + (x_), _poly\center\y + (y_),-1)
_poly\radius = Sqr( (x_)*(x_)+(y_)*(y_) )
_poly\p0\x = _poly\center\x + _poly\radius * Cos(_poly\angle + _poly\temp)
_poly\p0\y = _poly\center\y + _poly\radius * Sin(_poly\angle + _poly\temp)
_poly\p\x = _poly\p0\x
_poly\p\y = _poly\p0\y
_poly\Color = color_
_poly\relative = relative_
EndMacro
Macro setRadialPoly(x_, y_, color_=_poly\Color)
_poly\temp = getAngle(_poly\center\x, _poly\center\y, _poly\center\x + (x_), _poly\center\y + (y_),-1)
_poly\radius = Sqr( (x_)*(x_)+(y_)*(y_) )
_poly\go\x = _poly\center\x + _poly\radius * Cos(_poly\angle + _poly\temp)
_poly\go\y = _poly\center\y + _poly\radius * Sin(_poly\angle + _poly\temp)
LineXY( _poly\p\x, _poly\p\y, _poly\go\x, _poly\go\y, color_)
_poly\p\x = _poly\go\x
_poly\p\y = _poly\go\y
EndMacro
Macro rad(_deg_)
((_deg_)*0.017453292519943295) ; _deg_ * #PI / 180
EndMacro
; [merge_end]
;EXAMPLE
;
hWin=OpenWindow(0, 50,50,800,700, "c:\purebasic\include\getAngle.pbi")
CreateGadgetList(hWin)
ImageGadget(0, 0,0, 0,0, CreateImage(0,800,700), #PB_Image_Border)
AddKeyboardShortcut(0,#PB_Shortcut_Escape,0)
Font=LoadFont(0,"Arial",8)
Repeat
StartDrawing( ImageOutput(0) )
Box(0,0,WindowWidth(0),WindowHeight(0),$000000)
;a triangle
initPoly(50,300,$FF0000)
setPoly(100,0)
setPoly(-100,100)
closePoly()
;a polygon
initPoly(140,20,$FFFF00,#False)
setPoly(190,70)
setPoly(240,70)
setPoly(240,20,$00FF00)
setPoly(270,20)
setPoly(270,220)
setPoly(220,220,$0000FF)
setPoly( 20,20,$0000FF)
setPoly(140,20)
;a spiral
amount = DesktopMouseY()/4
angle.f = DesktopMouseX()/10
initPoly(400,200)
For i=1 To amount
setPolyA( rad(angle), i, RGB(255,255*i/amount,0) )
Next
;a bzzz
For n=0 To 4
initPoly(100,500)
For i=0 To 150
setPoly(4, Random(8)-4, $FF0000+$0000FF*i/150)
Next
Next
;a whirling star
Size=50
initPoly(300,350,$00FF00)
For n=1 To DesktopMouseX()/30
setPolyA(rad(175),Size)
setPolyA(rad(-160),Size+(DesktopMouseY()-400)/40)
Next
;an angled box
width=180
Height=40
angle=DesktopMouseX()/10
initPoly(400,400)
setPolyA(rad(angle),Width)
setPolyA(rad(90),Height)
setPolyA(rad(90),Width)
closePoly()
;another angled box (centered)
A=20
b=80
angle=DesktopMouseX()/10
Circle(450,510,3,$00FF00)
initRadialPolyA(450,510,rad(angle),50)
setRadialPolyA(rad(180*A/b),50)
setRadialPolyA(rad(180-180*A/b),50)
setRadialPolyA(rad(180*A/b),50)
closePoly()
;an angled ellipse
r1 = 100
r2 = 50
angle = DesktopMouseY()
min = DesktopMouseX()
max = min+356-45
Circle(200,600,3,$0000FF)
initRadialPoly(200,600,r1*Cos(rad(min)),r2*Sin(rad(min)),rad(angle),$0000FF)
For i=min To max
setRadialPoly(r1*Cos(rad(i)),r2*Sin(rad(i)))
Next
;closePoly()
StopDrawing()
SetGadgetState(0,ImageID(0))
event=WaitWindowEvent(40)
Select event
Case #PB_Event_CloseWindow
quit=1
Case #PB_Event_Menu
quit=1
EndSelect
Until quit
et celui ci qui est pas mal non plus
Code : Tout sélectionner
;Define
EnableExplicit
; 3D-Transformations - done by Michael Vogel
#pointsize=10
Global viewx.d,viewy.d,viewz.d
Global scale.d
Global screenx=640
Global screeny=480
Global offsetX=screenx>>1
Global offsetY=screeny>>1
Structure Mat
x.d[4]
y.d[4]
Z.d[4]
T.d[4]
EndStructure
Structure TripelPlus
x.d
y.d
Z.d
_X.l
_Y.l
_size.l
EndStructure
Structure Dupel
von.l
nach.l
EndStructure
Global Matrix.Mat
Global Calc.Mat
Global RotXMat.Mat
Global RotYMat.Mat
Global Camera.Mat
Global CamFD.d; focal distance: Fokusabstand
Global Punkte=8
Global Dim Points.TripelPlus(Punkte)
Global Linien=12
Global Dim Lines.Dupel(Linien)
Define i.l,x.w,y.w,Z.w
For i=1 To Punkte
Read x
Read y
Read Z
Points(i)\x=x
Points(i)\y=y
Points(i)\Z=Z
Next i
For i=1 To Linien
Read x
Read y
Lines(i)\von=x
Lines(i)\nach=y
Next i
DataSection
; Würfel-Eckepunkte
Data.w 50,50,50
Data.w -50,50,50
Data.w -50,-50,50
Data.w 50,-50,50
Data.w 50,50,-50
Data.w -50,50,-50
Data.w -50,-50,-50
Data.w 50,-50,-50
EndDataSection
DataSection
; Würfel-Kanten
Data.w 1,2,2,3,3,4,4,1
Data.w 1,5,2,6,3,7,4,8
Data.w 5,6,6,7,7,8,8,5
EndDataSection
; EndDefine
Procedure SetNorm(*m.Mat)
*m\x[0]=1 : *m\y[0]=0 : *m\Z[0]=0 : *m\T[0]=0
*m\x[1]=0 : *m\y[1]=1 : *m\Z[1]=0 : *m\T[1]=0
*m\x[2]=0 : *m\y[2]=0 : *m\Z[2]=1 : *m\T[2]=0
*m\x[3]=0 : *m\y[3]=0 : *m\Z[3]=0 : *m\T[3]=1
EndProcedure
Procedure SetTransformation(*m.Mat, x.d, y.d, Z.d)
*m\x[0]=1 : *m\y[0]=0 : *m\Z[0]=0 : *m\T[0]=0
*m\x[1]=0 : *m\y[1]=1 : *m\Z[1]=0 : *m\T[1]=0
*m\x[2]=0 : *m\y[2]=0 : *m\Z[2]=1 : *m\T[2]=0
*m\x[3]=x : *m\y[3]=y : *m\Z[3]=Z : *m\T[3]=1
EndProcedure
Procedure SetScale(*m.Mat, x.d, y.d, Z.d)
*m\x[0]=x : *m\y[0]=0 : *m\Z[0]=0 : *m\T[0]=0
*m\x[1]=0 : *m\y[1]=y : *m\Z[1]=0 : *m\T[1]=0
*m\x[2]=0 : *m\y[2]=0 : *m\Z[2]=Z : *m\T[2]=0
*m\x[3]=0 : *m\y[3]=0 : *m\Z[3]=0 : *m\T[3]=1
EndProcedure
Procedure SetRotX(*m.Mat, angle.d)
Protected s.d=Sin(angle)
Protected C.d=Cos(angle)
*m\x[0]=1 : *m\y[0]=0 : *m\Z[0]=0 : *m\T[0]=0
*m\x[1]=0 : *m\y[1]=C : *m\Z[1]=s : *m\T[1]=0
*m\x[2]=0 : *m\y[2]=-s : *m\Z[2]=C : *m\T[2]=0
*m\x[3]=0 : *m\y[3]=0 : *m\Z[3]=0 : *m\T[3]=1
EndProcedure
Procedure SetRotY(*m.Mat, angle.d)
Protected s.d=Sin(angle)
Protected C.d=Cos(angle)
*m\x[0]=C : *m\y[0]=0 : *m\Z[0]=s : *m\T[0]=0
*m\x[1]=0 : *m\y[1]=1 : *m\Z[1]=0 : *m\T[1]=0
*m\x[2]=-s : *m\y[2]=0 : *m\Z[2]=C : *m\T[2]=0
*m\x[3]=0 : *m\y[3]=0 : *m\Z[3]=0 : *m\T[3]=1
EndProcedure
Procedure SetRotZ(*m.Mat, angle.d)
Protected s.d=Sin(angle)
Protected C.d=Cos(angle)
*m\x[0]=C : *m\y[0]=s : *m\Z[0]=0 : *m\T[0]=0
*m\x[1]=-s : *m\y[1]=C : *m\Z[1]=0 : *m\T[1]=0
*m\x[2]=0 : *m\y[2]=0 : *m\Z[2]=1 : *m\T[2]=0
*m\x[3]=0 : *m\y[3]=0 : *m\Z[3]=0 : *m\T[3]=1
EndProcedure
Procedure Multiply(*m.Mat,*n.Mat,*result.Mat)
*result\x[0]=*m\x[0]**n\x[0] + *m\x[1]**n\y[0] + *m\x[2]**n\Z[0] + *m\x[3]**n\T[0]
*result\y[0]=*m\y[0]**n\x[0] + *m\y[1]**n\y[0] + *m\y[2]**n\Z[0] + *m\y[3]**n\T[0]
*result\Z[0]=*m\Z[0]**n\x[0] + *m\Z[1]**n\y[0] + *m\Z[2]**n\Z[0] + *m\Z[3]**n\T[0]
*result\T[0]=*m\T[0]**n\x[0] + *m\T[1]**n\y[0] + *m\T[2]**n\Z[0] + *m\T[3]**n\T[0]
*result\x[1]=*m\x[0]**n\x[1] + *m\x[1]**n\y[1] + *m\x[2]**n\Z[1] + *m\x[3]**n\T[1]
*result\y[1]=*m\y[0]**n\x[1] + *m\y[1]**n\y[1] + *m\y[2]**n\Z[1] + *m\y[3]**n\T[1]
*result\Z[1]=*m\Z[0]**n\x[1] + *m\Z[1]**n\y[1] + *m\Z[2]**n\Z[1] + *m\Z[3]**n\T[1]
*result\T[1]=*m\T[0]**n\x[1] + *m\T[1]**n\y[1] + *m\T[2]**n\Z[1] + *m\T[3]**n\T[1]
*result\x[2]=*m\x[0]**n\x[2] + *m\x[1]**n\y[2] + *m\x[2]**n\Z[2] + *m\x[3]**n\T[2]
*result\y[2]=*m\y[0]**n\x[2] + *m\y[1]**n\y[2] + *m\y[2]**n\Z[2] + *m\y[3]**n\T[2]
*result\Z[2]=*m\Z[0]**n\x[2] + *m\Z[1]**n\y[2] + *m\Z[2]**n\Z[2] + *m\Z[3]**n\T[2]
*result\T[2]=*m\T[0]**n\x[2] + *m\T[1]**n\y[2] + *m\T[2]**n\Z[2] + *m\T[3]**n\T[2]
*result\x[3]=*m\x[0]**n\x[3] + *m\x[1]**n\y[3] + *m\x[2]**n\Z[3] + *m\x[3]**n\T[3]
*result\y[3]=*m\y[0]**n\x[3] + *m\y[1]**n\y[3] + *m\y[2]**n\Z[3] + *m\y[3]**n\T[3]
*result\Z[3]=*m\Z[0]**n\x[3] + *m\Z[1]**n\y[3] + *m\Z[2]**n\Z[3] + *m\Z[3]**n\T[3]
*result\T[3]=*m\T[0]**n\x[3] + *m\T[1]**n\y[3] + *m\T[2]**n\Z[3] + *m\T[3]**n\T[3]
EndProcedure
Procedure Recalc()
Protected i
Multiply(@Camera,@Matrix,@Calc)
For i=1 To Punkte
With Points(i)
viewx = \x*Calc\x[0] + \y*Calc\x[1] + \Z*Calc\x[2] + Calc\x[3]
viewy = \x*Calc\y[0] + \y*Calc\y[1] + \Z*Calc\y[2] + Calc\y[3]
viewz = \x*Calc\Z[0] + \y*Calc\Z[1] + \Z*Calc\Z[2] + Calc\Z[3]
scale=CamFD/viewz
\_X=viewx*scale+offsetX
\_Y=viewy*scale+offsetY
\_size=scale*#pointsize
EndWith
Next i
EndProcedure
Procedure redraw()
Protected i.w
StartDrawing(ScreenOutput())
Box(0,0,screenx,screeny,$F0F0F0)
For i=1 To Punkte
Circle(Points(i)\_X,Points(i)\_Y,Points(i)\_size,$E04040)
Next i
For i=1 To Linien
LineXY(Points(Lines(i)\von)\_X,Points(Lines(i)\von)\_Y,Points(Lines(i)\nach)\_X,Points(Lines(i)\nach)\_Y,$8080F0)
Next i
StopDrawing()
EndProcedure
Procedure Text(x.l,y.l,v.d)
StartDrawing(ScreenOutput())
DrawText(x,y,StrD(v,3))
StopDrawing()
EndProcedure
Procedure Window()
Global win=OpenWindow(0,0,0,screenx,screeny,"3D",#PB_Window_ScreenCentered)
InitSprite()
OpenWindowedScreen(WindowID(0),0,0,screenx,screeny,0,0,0)
SetTimer_(win,1,100,0)
EndProcedure
Procedure Init()
CamFD=200
SetTransformation(@Camera,0,0,200)
EndProcedure
Procedure Main()
SetNorm(@Matrix)
Window()
Repeat
FlipBuffers(1)
Recalc()
redraw()
Text(10,50,CamFD)
Text(10,70,scale)
Select WaitWindowEvent()
Case #WM_TIMER
;n+1
;SetRoty(@Camera,n/#PI/2)
Case #WM_CHAR
Break
Case #WM_LBUTTONDOWN
;
Case #WM_RBUTTONDOWN
;
Case #WM_MOUSEMOVE
If GetKeyState_(#VK_SHIFT)&128
SetTransformation(@Matrix,WindowMouseX(0)-offsetX,WindowMouseY(0)-offsetY,0)
ElseIf GetKeyState_(#VK_CONTROL)&128
SetScale(@Matrix,WindowMouseX(0)/100,WindowMouseY(0)/100,1)
Else
SetRotX(@RotXMat,WindowMouseY(0)/100)
SetRotY(@RotYMat,WindowMouseX(0)/100)
Multiply(@RotXMat,@RotYMat,@Matrix)
EndIf
EndSelect
ForEver
KillTimer_(win,1)
EndProcedure
Init()
Main()