CodingTrain / CodingTrain/Nebula-AppleSoft-Basic
Rotation matrix may be computed just once
- Vorherrschende Sprache
- BASIC
- Sterne
- 51
- Forks
- 14
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
This might speed up the simulation, but probably not enough to have an acceptable frame rate in real time. So I guess you would still need to make a time lapse. In that regard, I'm not sure this is worth the trouble.
What the code does now is increment the rotation angle every loop by 1 degree, construct a new rotation matrix and use that matrix only once. Alternatively, you could construct a rotation matrix just once, before the draw loop, with an angle of 1 degree. Then use that matrix every time to transform the current coordinates. This will have the same effect, cumulatively. So instead of using sin and cos every loop *and* do the matrix multiplication, you have only the multiplication left.
One slight complication is that matrix multiplication p' = R.p can't be done in-place, because the old values would be overwritten when you still need them. So in BASIC, this probably requires juggling with array indices where you transform p(0..7) into p(8..15) on one loop, and p(8..15) into p(0..7) on the next loop.
I hope this is clear and that it will be helpful. Cheers!
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne bei der Draw-Schleife und verfolge, wie der Rotationswinkel, die Rotationsmatrix und die Koordinatenarrays p(0..7) und p(8..15) verwendet werden. Vergleiche die aktuelle Erstellung der Matrix pro Schleifendurchlauf damit, eine feste 1-Grad-Matrix wiederzuverwenden und die Koordinatenarrays abwechselnd zu verwenden; abgeschlossen ist die Aufgabe, wenn die kumulative Rotation denselben Effekt hat, ohne die Matrix in jedem Schleifendurchlauf neu zu erstellen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Bereich
- computer-graphics
- Issue-Typ
- Refactoring
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100