» »

program ne dela-prosim pomoč(VB)

program ne dela-prosim pomoč(VB)

]Fusion[ ::

Moja koda:

Form:

Const PI = 3.141592654
Const FOCUS = 300

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
Zavrti (5)
Case vbKeyLeft
Zavrti (-5)
End Select
End Sub

Private Sub Form_Load()

Dim n As Integer

With Dots(1)
.Xk = 100
.Yk = 100
.Zk = -100
End With

With Dots(2)
.Xk = 100
.Yk = -100
.Zk = -100
End With

With Dots(3)
.Xk = -100
.Yk = -100
.Zk = -100
End With

With Dots(4)
.Xk = -100
.Yk = 100
.Zk = -100
End With

With Dots(5)
.Xk = 100
.Yk = 100
.Zk = 100
End With

With Dots(6)
.Xk = 100
.Yk = -100
.Zk = 100
End With

With Dots(7)
.Xk = -100
.Yk = -100
.Zk = 100
End With

With Dots(8)
.Xk = -100
.Yk = 100
.Zk = 100
End With

For n = 1 To 8
Draw_Dots (n)
Next n
End Sub

Private Sub Draw_Dots(index)
Dim scX As Long
Dim scY As Long
scX = FOCUS * Dots(index).Xk / (Dots(index).Zk + 250)
scY = FOCUS * Dots(index).Yk / (Dots(index).Zk + 250)
With Line1(index - 1)
.X1 = scX
.X2 = scX
.Y1 = scY
.Y2 = scY
End With
End Sub

Private Sub Zavrti(Kot As Double)
Dim n As Integer
Dim SinKot, CosKot
Dim RadKot As Double
RadKot = CRad(Kot)
SinKot = Sin(RadKot)
CosKot = Cos(RadKot)
For n = 1 To 8
Dots(n).Xk = Dots(n).Zk * SinKot + Dots(n).Xk * CosKot
Dots(n).Zk = Dots(n).Zk * CosKot - Dots(n).Xk * SinKot
Draw_Dots (n)
Next n
End Sub

Function CRad(Deg) As Double
CRad = Deg * (PI / 180)
End Function

Module:

Type Dot
Xk As Long
Yk As Long
Zk As Long
End Type

Public Dots(8) As Dot

Vse dela lepo samo kocko mi med vrtenjem popači(postaja vedno tanjša) in ne vem v čem je problem.

PLEASE HELP!!!

Thomas ::

Kolikor na hitro vidim, je problem v tem:

>Dots(n).Xk = Dots(n).Zk * SinKot + Dots(n).Xk * CosKot
>Dots(n).Zk = Dots(n).Zk * CosKot - Dots(n).Xk * SinKot

X.k, ki ga dobiš v prvi liniji, takoj ponucaš v tadrugi. Potem se ti pa ta učinek kopiči.

Moraš imet ene vmesne spremenljivke!

:)

Man muss immer generalisieren - Carl Jacobi

]Fusion[ ::

Seveda!8-O Zdaj ko vidim rešitev bi se kar vstrelo!

Hvala


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

vb.net: dynamic textbox

Oddelek: Programiranje
51180 (1070) saule
»

visual basic 2008 express edition

Oddelek: Programiranje
221815 (1242) sel
»

VB in kk dobit Ip od račnalnika

Oddelek: Programiranje
81206 (1040) alesrosina
»

API+VB

Oddelek: Programiranje
262091 (1795) webblod
»

Visual basic Progress bar

Oddelek: Programiranje
51562 (1495) Lunik

Več podobnih tem