|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
[C++] esercizio: chi mi aiuta?
[C++] esercizio: chi mi aiuta?
avete un numero "n" noto che varia nel tempo. questo numero può aumentare o diminuire ma non vi interessa come aumenta o diminuisce. voi, istante per istante, sapete che il numero varia e conoscete in ogni istante quanto vale. al massimo potete ricordare quanto valeva nell'istante prima. ma in generale sapete solo il valore attuale. se il numero è positivo e decresce, scende sino a zero e poi inizia a diminuire come numero negativo. se il numero è negativo ad aumenta, sale sino a zero e poi inizia ad aumentare come numero positivo. però (e qui il difficile) vorrei usare un altro numero "k" che è una "modifica" del numero n. A) se n positivo aumenta o n negativo diminuisce ------------------------------------------------- 1) se n>0, k(>0 anch'esso) deve restare confinato nella zona 0-->6 esempio: n=0 --> 2 --> 4 --> 6 --> 6.1 --> 8 --> 10 --> 11.9 --> 12 --> 14 --> ... k=0 --> 2 --> 4 --> 6 --> 0.1 --> 2 --> 4 --> 5.9 --> 6 --> 2 --> ... 2) se n<0, k(<0 anch'esso) deve restare confinato nella zona 0-->-6 n=0 --> -2 --> -4 --> -6 --> -6.1 --> -8 --> -10 --> -12 --> -14 --> ... k=0 --> -2 --> -4 --> -6 --> -0.1 --> -2 --> -4 --> -6 --> -2 --> ... B) se n negativo aumenta o n positivo diminuisce ------------------------------------------------ in questo caso se k va a zero poi non deve saltare al numero positivo massimo o negativo massimo ma deve cambiare segno. mi spiego con un esempio pratico nel caso n positivo che diminuisce avendo n=16 --> 14 --> 12.1 --> 12 --> 11.9 --> 10 --> 8 --> 6 --> 4 -->... NON voglio k=16 --> 2 --> 0.1 --> 6 --> 5.9 --> 4 --> 2 --> 6 --> 4 -->... MA voglio k=16 --> 2 --> 0.1 --> _0_ --> -0.1 --> -2 --> -4 --> -6 --> 0 --> -2 --> .... viceversa se ho n negativo ed aumenta ho provato a pensare come fare ma non ci arrivo. avete idea di come fare???? NOTA BENE: non usate gli int ma i double perchè qui ho fatto esempioi di multipli di 6. in realtà sono angoli in radianti e quindi multipli di 6.28. il "6" era solo per far capire. inoltre tali numeri aumentano lentamente es: 5.21234 5.21301 5.21409 ... .. . quindi per forza sono double. chi mi sa aiutare?
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
|
Praticamente: se stessimo lavorando con dei numeri interi, vorresti il modulo della divisione per 6 (o del numero che tu fissi).
Siccome stiamo lavorando con i double ed intendi "dividere" per un numero reale, questo discorso non tiene. Pero' potresti semplicemente sottrarre il tuo numero (6.28) al tuo numero n di partenza, e ripetere l'operazione fintanto che il tuo numero rientra nell'intervallo che ti interessa. NOTA - parlo di sottrarre poiche' puoi lavorare con i valori assoluti, salvando preliminarmente il segno. Applicherai poi il segno al risultato High Flying Sottovento
__________________
In God we trust; all others bring data |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
hehehe
chi si rivede ![]() mumble mumble vediamo un po': è un robot che gira su se stesso e ho l'angolo "theta" che mi dice quanto è ruotato rispetto ad una posizione di riferimento fissa. double theta; (diamo per scontato che ad ogni ciclo viene assegnato a theta il valore attuale dell'angolo del robot. il mio programma lo estrae con una libreria apposita quindi diamolo per scontato) theta=...; ad ogni ciclo parte da li (theta=0) e gira in senso antiorario (theta>0 se gira antiorario). l'angolo aumenta. quando il robot ha girato su se stesso del tutto arrivo a 6.28. Quando lo supero sottraggo 6.28 e resto nell'ambito 0-6.28. chiamiamo l'angolo "taroccato" theta_mod. double theta_mod; theta_mod=theta; if (theta_mod >6.28) [theta_mod=theta-6.28]; ma dove diavolo sono le parentesi graffe sulla tastiera? Il robot continua a girare nel secondo giro. Al termine del secondo giro l'angolo "vero" è theta=2*6.28=12.56 mentre quello taroccato è theta_mod=6.28. a quel punto l'algoritmo toppa perchè sottrea "solo" 6.28 mentre dovrebbe sottrarree 2*6.28. basta però implementare un contatore "k" che aumento di uno ogni volta che theta_mod>6.28 e fare "theta_mod=theta-k*6.28". quindi scartiamo quanto detto prima e diciamo: inizializzo k=0; if (theta_mod >6.28) [k=k+1]; theta_mod=theta-k*6.28; vediamo come funziona: primo giro ------------ theta=6.28+qualcosa. è oltre 6.28 quindi k scatta a 1 k=1 theta_mod=theta-k*6.28 secondo giro -------------- theta=2*6.28+qualcosa thetamod è arrivato a 6.28+qualcosa quindi di nuovo oltre 6.28 quindi k scatta a 2 theta_mod=theta-k*6.28 .etc etc in questo modo theta può anche arrivare a n*6.28 (n giri) ma theta_mod sta sempre dentro 0-6.28 grazie alla theta_mod=theta-k*6.28 essendo k=n. stessa cosa se il robot gira in senso antiorario: li sommerò 6.28 e alla fine avrò, con simile ragionamento, che theta(ora <0) può anche arrivare a -n*6.28 (n giri) ma theta_mod sta sempre dentro 0-(-6.28). questo era facile. il problema è che il robot non gira solo in un verso ma si può fermare e cambiare verso di rotazione. ipotizziamo che il robot abbia già percorso 3 giri antiorari (quindi theta>0) più un pezzetto : siamo a theta 3*6.28+qualcosa=18.84+qualcosa ad esempio theta=20. il nostro theta_mod logicamente ci indica theta_mod=20-3*6.28=20-18.84=1.16 con k=3 ora il robot si ferma e torna indietro. ricordiamo che l'algoritmo che domina è: theta_mod=theta-3*6.28 (k=3) theta=20 theta_mod=20-3*6.28=1.16 theta=18.85 (=3*6.28+0.01) theta_mod=theta-3*6.28=18.85-18.84=0.01 theta=18.84 (=3*6.28) theta_modtheta-3*6.28=18.84-18.84=0 il robot è nella posizione di diferimento e gira in senso orario. quindi da ora vorremmo avere segno <0. vediamo se accade: theta=18.83 (=3*6.28-0.01) theta_mod=theta-3*6.28=18.83-18.84=-0.01 <0 ok MA scendendo ancora, dopo un altro giro orario, alla fine arrivo a theta=2*6.28. e theta_mod? la k non viene più modificata perchè non avverrà mai più theta_mod>6.28 visto che theta_mod sta andando verso numeri negativi. quindi avremmo theta_mod=theta-3*6.28=2*6.28-3*6.28=-6.28<0 ma andando oltre (il robot ancora gira in senso orario)a vbrei thetamod -6.29 -->-6.30 --> -7 --> -9 -->..... non va. non deve scendere sotto -6.28 quindi aggiungiamo un if (theta_mod <-6.28) [k=k-1]; ora dovrebbe andare. mi sento il cervello fuso. mi confermi che quanto detto funziona o ci sono errori che non vedo? quando theta=0 dovrebbe essere theta_mod=0 e k=0. poi theta cala a numeri negativi e thetamod anche ma ogni volta che supera -6.28 il k cala di uno e la formula theta_mod=theta-k*6.28 in realtà è theta_mod=theta+abs(k)*6.28 visto che k<0 (k=-1, -2, -3) però qui cade l'asino. siamo a theta=-3.28-qualcosa=-20. cambiamo direzione. come faccio a far aumentare la k? non aumenta con il primo "if" perchè k non è mai >+6.28 non aumenta mai con il secondo if perchè theta_mod non scende più sotto -6.28. come contemplo questo caso??????? theta_mod -20-- -19.9 --> -19-5 -->...?
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII Ultima modifica di vermaccio : 05-04-2006 alle 15:59. |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
ho modificato la parte finale scritta qui sopra.
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#5 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
theta_mod -20-- -19.9 --> -19-5 -->...?
cioè il robot gira di nuovo in senso antiorario quindi theta risale verso i valori positivi. theta=-20 k=-3 thetamod=theta-k*6.28=-20+3*6.28=18.84=-1.16 theta=-18.85 k=-3 thetamod=theta-k*6.28=-18.85+3*6.28=18.84=-0.01 theta=-18.84 k=-3 thetamod=theta-k*6.28=-18.84+3*6.28=18.84=0 !!!!! theta=-18.83 k=-3 thetamod=theta-k*6.28=-18.83+3*6.28=+0.01 >0 ok! da ora in poi theta_mosd aumenta ma quando arriva a 6.28 ecco che si attiva k=k+1 quindi riscende a zero. (se era k=-3 diventa k=-2) così dovrebbe andare?
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#6 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
test I
INIZIALIZZAZIONE:
double theta: double theta_mod; int k=0; CICLO INFINITO (non devo scriverlo. la libreia che uso prevede due parti di codice: una di inizializzazione euna che verrà eseguita all'infinito. Nella prima creo le variabili globali e le inizializzo. Nella seconda metto gli algoritmi.) theta=...;(qui c'è istruzione proprietaria che mi dice quanto vale theta in questo ciclo) theta_mod=theta; if (theta_mod >6.28) [k=k+1]; if (theta_mod <-6.28) [k=k-1]; if (theta_mod >6.28) [theta_mod=theta-k*6.28]; in questo modo theta va da -inf a +inf ma theta_mod sta sempre tra -6.28 e +6.28. me lo confermi o ci sono errori?
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#7 |
Senior Member
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
|
Ciao!
Non complicarti la vita: ti basta un ciclo while che riporti il valore dell'angolo nell'intervallo che ti interessa. Per farlo: - se il numero e' positivo, sottrai 2*pi; - se il numero e' negativo, somma 2 * pi; Rispetto a quello che ti ho detto nella mail prima (non sapevo che il problema era questo), NON lavorare sui valori assoluti, avresti degli errori di calcolo. High Flying Sottovento
__________________
In God we trust; all others bring data |
![]() |
![]() |
![]() |
#8 | |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
Quote:
ho scritto questo Codice:
#include<stdio.h> #include <math.h> void main(void) { double theta; double theta_mod; double k=0.0; theta=5.4; while (theta < 20.0){ theta_mod=theta; if (theta_mod >6.28) k=k+1; if (theta_mod <-6.28) k=k-1; theta_mod=theta-k*6.28; printf("k:%g\n", k ); printf("theta: %g,theta_mod: %g\n", theta, theta_mod ); theta=theta+0.2; } } perchè? non lo capisco k:0 theta: 5.4,theta_mod: 5.4 k:0 theta: 5.6,theta_mod: 5.6 k:0 theta: 5.8,theta_mod: 5.8 k:0 theta: 6,theta_mod: 6 k:0 theta: 6.2,theta_mod: 6.2 k:1 OK! theta: 6.4,theta_mod: 0.12 k:2 ???? theta: 6.6,theta_mod: -5.96 k:3 ??? theta: 6.8,theta_mod: -12.04 k:4 ?? theta: 7,theta_mod: -18.12
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII Ultima modifica di vermaccio : 05-04-2006 alle 16:18. |
|
![]() |
![]() |
![]() |
#9 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
risolto.
avevo messo l'istruzione dopo gli if
questo funziona con i positivi. ora testo i negativi #include<stdio.h> #include <math.h> void main(void) { double theta; double theta_mod; double k=0.0; theta=5.4; while (theta < 20.0){ theta_mod=theta; theta_mod=theta-k*6.28; if (theta_mod >6.28) k=k+1; if (theta_mod <-6.28) k=k-1; printf("k:%g\n", k ); printf("theta: %g,theta_mod: %g\n", theta, theta_mod ); theta=theta+0.2; } }
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#10 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
ok funziona.
unico "bug": se il theta inziale del primo ciclo è <6.28 o minore di -6.28 allora essendo stato inializzato k=0 si hahno errori. dato un numero n come faccio a sapere quante volte 6.28 ci entra? es: n=7 --> 6.28 ci entra 1 volta ed ho un certo resto che non mi interessa. questo "1" volta è k iniziale da settare prima del while!!! n=20 --> 6.28 ci entra 3 volte ed ho un certo resto (1.16) che nion mi interessa. questo "32 è il k iniziale da settare prima del while esiste un istruzione c++ che vede quante volte un numero entra in un altro? mi raccomnado numeri double e che dunzioni anche con i negativi. esempio n=20 deve dare 3 n=-20 deve dare -3 vabbè che sul negativo non c'è problema: se n=-20<0 faccio il calcolo su -n=20>0 e il "3" che esce poi lo giro di segno "-3"
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#11 |
Senior Member
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
|
Ciao,
veramente quello che intendevo e' che la sottrazione/somma la fai in un ciclo while. Cosi' non hai piu' il problema di contare i k (che e' piuttosto difficile), no? Codice:
modifiedAngle = theta; angleSign = (theta > 0.0)? 1.0 : (theta < 0.0) ? -1.0 : 0.0; toBeSubtracted = angleSign * 6.28; while (angleSign * modifiedAngle > 6.28) modifiedAngle -= toBeSubtracted; In pratica: - se il numero e' positivo, continuerai a sottrarre 6.28 fino a stare nell'intervallo desiderato; - se il numero e' negativo, sommerai 6.28 fino ad entrare nell'intervallo desiderato. - le variabili sono tutte double Tutto qui. High Flying Sottovento
__________________
In God we trust; all others bring data |
![]() |
![]() |
![]() |
#12 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
modifiedAngle -= toBeSubtracted;
che rispetto modifiedAngle = toBeSubtracted; ? e se metto +?
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#13 |
Senior Member
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
|
Ciao!!
Non ho capito bene la domanda. Comunque ho messo una sottrazione perche' il segno della parte da sottrarre e' "invertito". Se vuoi mettere il += invece di -= devi ovvamente invertire il segno della parte da sottrarre (e magari mettere un nome del tipo toBeAdded). High Flying Sottovento
__________________
In God we trust; all others bring data |
![]() |
![]() |
![]() |
#14 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
modifiedAngle -= toBeSubtracted;
intendevo chiedere che significa: per caso è equivalemnte a dire modifiedAngle = modifiedAngle-toBeSubtracted; ??? e invece un modifiedAngle += toBeSubtracted; equivale ad un modifiedAngle = modifiedAngle+toBeSubtracted; ??
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#15 | |
Senior Member
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
|
Quote:
NOTA (solo per curiosita') - Mi e' capitato di lavorare con compilatori per piattaforme dedicate alla risoluzione di particolari problemi. Su queste piattaforme, a causa di alcuni problemi sorti durante la codifica, ho dovuto approfondire alcuni aspetti, fra i quali il tipo di codice generato dal compilatore. Sembrera' strano (non piu' di tanto, tutto sommato), ma le espressioni a += b; a -=b; generano un codice piu' veloce e compatto di a = a + b; a = a - b; A sua volta, il codice macchina generato per istruzioni quali a++; --a; e' ulteriormente ottimizzato. High Flying Sottovento
__________________
In God we trust; all others bring data |
|
![]() |
![]() |
![]() |
#16 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
però se da una parte c'è ottimizzazione del codice, dall'altra si perde in visibilità, comprensibilità umana "al volo"
![]() ino0ltre la riga angleSign = (theta > 0.0)? 1.0 : (theta < 0.0) ? -1.0 : 0.0; devo interpretarla come: variabile = (condizione1)? valore1 : (condizione2) ? valore2 : valore3; ovvero: se è vera la condizione 1 allora variabile=valore1 se è vera la condizione 2 allora variabile=valore2 se nessuna delle due condizioni è vera allora valore=valore3 esatto? quindi in generale variabile = (condizione1)? valore1 : (condizione2) ? valore2 :......: (condizione_n) ? valore_n : valore_n+1;
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#17 |
Senior Member
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
|
Esatto! E sono esatte anche le considerazioni sulla leggibilita'
High Flying Sottovento
__________________
In God we trust; all others bring data |
![]() |
![]() |
![]() |
#18 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
Listato funzionante definitivo
Codice:
#include<stdio.h> #include <math.h> void main(void) { double theta; theta=15.4; while (theta > -14){//ciclo while per testare double modifiedAngle= theta; double angleSign = (theta > 0.0)? 1.0 : (theta < 0.0) ? -1.0 : 0.0; double toBeSubtracted = angleSign * 6.28; while (angleSign * modifiedAngle > 6.28) modifiedAngle = modifiedAngle-toBeSubtracted; //equivale a dire modifiedAngle -= toBeSubtracted; printf("theta: %g, segno: %g,modifiedAngle: %g\n", theta, angleSign,modifiedAngle ); theta=theta-0.2; //ciclo while per testare } //ciclo while per testare } ecco cosa accade compilando ed avviando: Codice:
theta: 15.4, segno: 1,modifiedAngle: 2.84 theta: 15.2, segno: 1,modifiedAngle: 2.64 theta: 15, segno: 1,modifiedAngle: 2.44 theta: 14.8, segno: 1,modifiedAngle: 2.24 theta: 14.6, segno: 1,modifiedAngle: 2.04 theta: 14.4, segno: 1,modifiedAngle: 1.84 theta: 14.2, segno: 1,modifiedAngle: 1.64 theta: 14, segno: 1,modifiedAngle: 1.44 theta: 13.8, segno: 1,modifiedAngle: 1.24 theta: 13.6, segno: 1,modifiedAngle: 1.04 theta: 13.4, segno: 1,modifiedAngle: 0.84 theta: 13.2, segno: 1,modifiedAngle: 0.64 theta: 13, segno: 1,modifiedAngle: 0.44 theta: 12.8, segno: 1,modifiedAngle: 0.24 theta: 12.6, segno: 1,modifiedAngle: 0.04 theta: 12.4, segno: 1,modifiedAngle: 6.12 theta: 12.2, segno: 1,modifiedAngle: 5.92 theta: 12, segno: 1,modifiedAngle: 5.72 theta: 11.8, segno: 1,modifiedAngle: 5.52 theta: 11.6, segno: 1,modifiedAngle: 5.32 theta: 11.4, segno: 1,modifiedAngle: 5.12 theta: 11.2, segno: 1,modifiedAngle: 4.92 theta: 11, segno: 1,modifiedAngle: 4.72 theta: 10.8, segno: 1,modifiedAngle: 4.52 theta: 10.6, segno: 1,modifiedAngle: 4.32 theta: 10.4, segno: 1,modifiedAngle: 4.12 theta: 10.2, segno: 1,modifiedAngle: 3.92 theta: 10, segno: 1,modifiedAngle: 3.72 theta: 9.8, segno: 1,modifiedAngle: 3.52 theta: 9.6, segno: 1,modifiedAngle: 3.32 theta: 9.4, segno: 1,modifiedAngle: 3.12 theta: 9.2, segno: 1,modifiedAngle: 2.92 theta: 9, segno: 1,modifiedAngle: 2.72 theta: 8.8, segno: 1,modifiedAngle: 2.52 theta: 8.6, segno: 1,modifiedAngle: 2.32 theta: 8.4, segno: 1,modifiedAngle: 2.12 theta: 8.2, segno: 1,modifiedAngle: 1.92 theta: 8, segno: 1,modifiedAngle: 1.72 theta: 7.8, segno: 1,modifiedAngle: 1.52 theta: 7.6, segno: 1,modifiedAngle: 1.32 theta: 7.4, segno: 1,modifiedAngle: 1.12 theta: 7.2, segno: 1,modifiedAngle: 0.92 theta: 7, segno: 1,modifiedAngle: 0.72 theta: 6.8, segno: 1,modifiedAngle: 0.52 theta: 6.6, segno: 1,modifiedAngle: 0.32 theta: 6.4, segno: 1,modifiedAngle: 0.12 theta: 6.2, segno: 1,modifiedAngle: 6.2 theta: 6, segno: 1,modifiedAngle: 6 theta: 5.8, segno: 1,modifiedAngle: 5.8 theta: 5.6, segno: 1,modifiedAngle: 5.6 theta: 5.4, segno: 1,modifiedAngle: 5.4 theta: 5.2, segno: 1,modifiedAngle: 5.2 theta: 5, segno: 1,modifiedAngle: 5 theta: 4.8, segno: 1,modifiedAngle: 4.8 theta: 4.6, segno: 1,modifiedAngle: 4.6 theta: 4.4, segno: 1,modifiedAngle: 4.4 theta: 4.2, segno: 1,modifiedAngle: 4.2 theta: 4, segno: 1,modifiedAngle: 4 theta: 3.8, segno: 1,modifiedAngle: 3.8 theta: 3.6, segno: 1,modifiedAngle: 3.6 theta: 3.4, segno: 1,modifiedAngle: 3.4 theta: 3.2, segno: 1,modifiedAngle: 3.2 theta: 3, segno: 1,modifiedAngle: 3 theta: 2.8, segno: 1,modifiedAngle: 2.8 theta: 2.6, segno: 1,modifiedAngle: 2.6 theta: 2.4, segno: 1,modifiedAngle: 2.4 theta: 2.2, segno: 1,modifiedAngle: 2.2 theta: 2, segno: 1,modifiedAngle: 2 theta: 1.8, segno: 1,modifiedAngle: 1.8 theta: 1.6, segno: 1,modifiedAngle: 1.6 theta: 1.4, segno: 1,modifiedAngle: 1.4 theta: 1.2, segno: 1,modifiedAngle: 1.2 theta: 1, segno: 1,modifiedAngle: 1 theta: 0.8, segno: 1,modifiedAngle: 0.8 theta: 0.6, segno: 1,modifiedAngle: 0.6 theta: 0.4, segno: 1,modifiedAngle: 0.4 theta: 0.2, segno: 1,modifiedAngle: 0.2 theta: 2.15938e-014, segno: 1,modifiedAngle: 2.15938e-01 theta: -0.2, segno: -1,modifiedAngle: -0.2 theta: -0.4, segno: -1,modifiedAngle: -0.4 theta: -0.6, segno: -1,modifiedAngle: -0.6 theta: -0.8, segno: -1,modifiedAngle: -0.8 theta: -1, segno: -1,modifiedAngle: -1 theta: -1.2, segno: -1,modifiedAngle: -1.2 theta: -1.4, segno: -1,modifiedAngle: -1.4 theta: -1.6, segno: -1,modifiedAngle: -1.6 theta: -1.8, segno: -1,modifiedAngle: -1.8 theta: -2, segno: -1,modifiedAngle: -2 theta: -2.2, segno: -1,modifiedAngle: -2.2 theta: -2.4, segno: -1,modifiedAngle: -2.4 theta: -2.6, segno: -1,modifiedAngle: -2.6 theta: -2.8, segno: -1,modifiedAngle: -2.8 theta: -3, segno: -1,modifiedAngle: -3 theta: -3.2, segno: -1,modifiedAngle: -3.2 theta: -3.4, segno: -1,modifiedAngle: -3.4 theta: -3.6, segno: -1,modifiedAngle: -3.6 theta: -3.8, segno: -1,modifiedAngle: -3.8 theta: -4, segno: -1,modifiedAngle: -4 theta: -4.2, segno: -1,modifiedAngle: -4.2 theta: -4.4, segno: -1,modifiedAngle: -4.4 theta: -4.6, segno: -1,modifiedAngle: -4.6 theta: -4.8, segno: -1,modifiedAngle: -4.8 theta: -5, segno: -1,modifiedAngle: -5 theta: -5.2, segno: -1,modifiedAngle: -5.2 theta: -5.4, segno: -1,modifiedAngle: -5.4 theta: -5.6, segno: -1,modifiedAngle: -5.6 theta: -5.8, segno: -1,modifiedAngle: -5.8 theta: -6, segno: -1,modifiedAngle: -6 theta: -6.2, segno: -1,modifiedAngle: -6.2 theta: -6.4, segno: -1,modifiedAngle: -0.12 theta: -6.6, segno: -1,modifiedAngle: -0.32 theta: -6.8, segno: -1,modifiedAngle: -0.52 theta: -7, segno: -1,modifiedAngle: -0.72 theta: -7.2, segno: -1,modifiedAngle: -0.92 theta: -7.4, segno: -1,modifiedAngle: -1.12 theta: -7.6, segno: -1,modifiedAngle: -1.32 theta: -7.8, segno: -1,modifiedAngle: -1.52 theta: -8, segno: -1,modifiedAngle: -1.72 theta: -8.2, segno: -1,modifiedAngle: -1.92 theta: -8.4, segno: -1,modifiedAngle: -2.12 theta: -8.6, segno: -1,modifiedAngle: -2.32 theta: -8.8, segno: -1,modifiedAngle: -2.52 theta: -9, segno: -1,modifiedAngle: -2.72 theta: -9.2, segno: -1,modifiedAngle: -2.92 theta: -9.4, segno: -1,modifiedAngle: -3.12 theta: -9.6, segno: -1,modifiedAngle: -3.32 theta: -9.8, segno: -1,modifiedAngle: -3.52 theta: -10, segno: -1,modifiedAngle: -3.72 theta: -10.2, segno: -1,modifiedAngle: -3.92 theta: -10.4, segno: -1,modifiedAngle: -4.12 theta: -10.6, segno: -1,modifiedAngle: -4.32 theta: -10.8, segno: -1,modifiedAngle: -4.52 theta: -11, segno: -1,modifiedAngle: -4.72 theta: -11.2, segno: -1,modifiedAngle: -4.92 theta: -11.4, segno: -1,modifiedAngle: -5.12 theta: -11.6, segno: -1,modifiedAngle: -5.32 theta: -11.8, segno: -1,modifiedAngle: -5.52 theta: -12, segno: -1,modifiedAngle: -5.72 theta: -12.2, segno: -1,modifiedAngle: -5.92 theta: -12.4, segno: -1,modifiedAngle: -6.12 theta: -12.6, segno: -1,modifiedAngle: -0.04 theta: -12.8, segno: -1,modifiedAngle: -0.24 theta: -13, segno: -1,modifiedAngle: -0.44 theta: -13.2, segno: -1,modifiedAngle: -0.64 theta: -13.4, segno: -1,modifiedAngle: -0.84 theta: -13.6, segno: -1,modifiedAngle: -1.04 theta: -13.8, segno: -1,modifiedAngle: -1.24 theta: -14, segno: -1,modifiedAngle: -1.44 FINE Press any key to continue Codice:
theta: -15.4, segno: -1,modifiedAngle: -2.84 theta: -15.2, segno: -1,modifiedAngle: -2.64 theta: -15, segno: -1,modifiedAngle: -2.44 theta: -14.8, segno: -1,modifiedAngle: -2.24 theta: -14.6, segno: -1,modifiedAngle: -2.04 theta: -14.4, segno: -1,modifiedAngle: -1.84 theta: -14.2, segno: -1,modifiedAngle: -1.64 theta: -14, segno: -1,modifiedAngle: -1.44 theta: -13.8, segno: -1,modifiedAngle: -1.24 theta: -13.6, segno: -1,modifiedAngle: -1.04 theta: -13.4, segno: -1,modifiedAngle: -0.84 theta: -13.2, segno: -1,modifiedAngle: -0.64 theta: -13, segno: -1,modifiedAngle: -0.44 theta: -12.8, segno: -1,modifiedAngle: -0.24 theta: -12.6, segno: -1,modifiedAngle: -0.04 theta: -12.4, segno: -1,modifiedAngle: -6.12 theta: -12.2, segno: -1,modifiedAngle: -5.92 theta: -12, segno: -1,modifiedAngle: -5.72 theta: -11.8, segno: -1,modifiedAngle: -5.52 theta: -11.6, segno: -1,modifiedAngle: -5.32 theta: -11.4, segno: -1,modifiedAngle: -5.12 theta: -11.2, segno: -1,modifiedAngle: -4.92 theta: -11, segno: -1,modifiedAngle: -4.72 theta: -10.8, segno: -1,modifiedAngle: -4.52 theta: -10.6, segno: -1,modifiedAngle: -4.32 theta: -10.4, segno: -1,modifiedAngle: -4.12 theta: -10.2, segno: -1,modifiedAngle: -3.92 theta: -10, segno: -1,modifiedAngle: -3.72 theta: -9.8, segno: -1,modifiedAngle: -3.52 theta: -9.6, segno: -1,modifiedAngle: -3.32 theta: -9.4, segno: -1,modifiedAngle: -3.12 theta: -9.2, segno: -1,modifiedAngle: -2.92 theta: -9, segno: -1,modifiedAngle: -2.72 theta: -8.8, segno: -1,modifiedAngle: -2.52 theta: -8.6, segno: -1,modifiedAngle: -2.32 theta: -8.4, segno: -1,modifiedAngle: -2.12 theta: -8.2, segno: -1,modifiedAngle: -1.92 theta: -8, segno: -1,modifiedAngle: -1.72 theta: -7.8, segno: -1,modifiedAngle: -1.52 theta: -7.6, segno: -1,modifiedAngle: -1.32 theta: -7.4, segno: -1,modifiedAngle: -1.12 theta: -7.2, segno: -1,modifiedAngle: -0.92 theta: -7, segno: -1,modifiedAngle: -0.72 theta: -6.8, segno: -1,modifiedAngle: -0.52 theta: -6.6, segno: -1,modifiedAngle: -0.32 theta: -6.4, segno: -1,modifiedAngle: -0.12 theta: -6.2, segno: -1,modifiedAngle: -6.2 theta: -6, segno: -1,modifiedAngle: -6 theta: -5.8, segno: -1,modifiedAngle: -5.8 theta: -5.6, segno: -1,modifiedAngle: -5.6 theta: -5.4, segno: -1,modifiedAngle: -5.4 theta: -5.2, segno: -1,modifiedAngle: -5.2 theta: -5, segno: -1,modifiedAngle: -5 theta: -4.8, segno: -1,modifiedAngle: -4.8 theta: -4.6, segno: -1,modifiedAngle: -4.6 theta: -4.4, segno: -1,modifiedAngle: -4.4 theta: -4.2, segno: -1,modifiedAngle: -4.2 theta: -4, segno: -1,modifiedAngle: -4 theta: -3.8, segno: -1,modifiedAngle: -3.8 theta: -3.6, segno: -1,modifiedAngle: -3.6 theta: -3.4, segno: -1,modifiedAngle: -3.4 theta: -3.2, segno: -1,modifiedAngle: -3.2 theta: -3, segno: -1,modifiedAngle: -3 theta: -2.8, segno: -1,modifiedAngle: -2.8 theta: -2.6, segno: -1,modifiedAngle: -2.6 theta: -2.4, segno: -1,modifiedAngle: -2.4 theta: -2.2, segno: -1,modifiedAngle: -2.2 theta: -2, segno: -1,modifiedAngle: -2 theta: -1.8, segno: -1,modifiedAngle: -1.8 theta: -1.6, segno: -1,modifiedAngle: -1.6 theta: -1.4, segno: -1,modifiedAngle: -1.4 theta: -1.2, segno: -1,modifiedAngle: -1.2 theta: -1, segno: -1,modifiedAngle: -1 theta: -0.8, segno: -1,modifiedAngle: -0.8 theta: -0.6, segno: -1,modifiedAngle: -0.6 theta: -0.4, segno: -1,modifiedAngle: -0.4 theta: -0.2, segno: -1,modifiedAngle: -0.2 theta: -2.15938e-014, segno: -1,modifiedAngle: -2.15938e-014 theta: 0.2, segno: 1,modifiedAngle: 0.2 theta: 0.4, segno: 1,modifiedAngle: 0.4 theta: 0.6, segno: 1,modifiedAngle: 0.6 theta: 0.8, segno: 1,modifiedAngle: 0.8 theta: 1, segno: 1,modifiedAngle: 1 theta: 1.2, segno: 1,modifiedAngle: 1.2 theta: 1.4, segno: 1,modifiedAngle: 1.4 theta: 1.6, segno: 1,modifiedAngle: 1.6 theta: 1.8, segno: 1,modifiedAngle: 1.8 theta: 2, segno: 1,modifiedAngle: 2 theta: 2.2, segno: 1,modifiedAngle: 2.2 theta: 2.4, segno: 1,modifiedAngle: 2.4 theta: 2.6, segno: 1,modifiedAngle: 2.6 theta: 2.8, segno: 1,modifiedAngle: 2.8 theta: 3, segno: 1,modifiedAngle: 3 theta: 3.2, segno: 1,modifiedAngle: 3.2 theta: 3.4, segno: 1,modifiedAngle: 3.4 theta: 3.6, segno: 1,modifiedAngle: 3.6 theta: 3.8, segno: 1,modifiedAngle: 3.8 theta: 4, segno: 1,modifiedAngle: 4 theta: 4.2, segno: 1,modifiedAngle: 4.2 theta: 4.4, segno: 1,modifiedAngle: 4.4 theta: 4.6, segno: 1,modifiedAngle: 4.6 theta: 4.8, segno: 1,modifiedAngle: 4.8 theta: 5, segno: 1,modifiedAngle: 5 theta: 5.2, segno: 1,modifiedAngle: 5.2 theta: 5.4, segno: 1,modifiedAngle: 5.4 theta: 5.6, segno: 1,modifiedAngle: 5.6 theta: 5.8, segno: 1,modifiedAngle: 5.8 theta: 6, segno: 1,modifiedAngle: 6 theta: 6.2, segno: 1,modifiedAngle: 6.2 theta: 6.4, segno: 1,modifiedAngle: 0.12 theta: 6.6, segno: 1,modifiedAngle: 0.32 theta: 6.8, segno: 1,modifiedAngle: 0.52 theta: 7, segno: 1,modifiedAngle: 0.72 theta: 7.2, segno: 1,modifiedAngle: 0.92 theta: 7.4, segno: 1,modifiedAngle: 1.12 theta: 7.6, segno: 1,modifiedAngle: 1.32 theta: 7.8, segno: 1,modifiedAngle: 1.52 theta: 8, segno: 1,modifiedAngle: 1.72 theta: 8.2, segno: 1,modifiedAngle: 1.92 theta: 8.4, segno: 1,modifiedAngle: 2.12 theta: 8.6, segno: 1,modifiedAngle: 2.32 theta: 8.8, segno: 1,modifiedAngle: 2.52 theta: 9, segno: 1,modifiedAngle: 2.72 theta: 9.2, segno: 1,modifiedAngle: 2.92 theta: 9.4, segno: 1,modifiedAngle: 3.12 theta: 9.6, segno: 1,modifiedAngle: 3.32 theta: 9.8, segno: 1,modifiedAngle: 3.52 theta: 10, segno: 1,modifiedAngle: 3.72 theta: 10.2, segno: 1,modifiedAngle: 3.92 theta: 10.4, segno: 1,modifiedAngle: 4.12 theta: 10.6, segno: 1,modifiedAngle: 4.32 theta: 10.8, segno: 1,modifiedAngle: 4.52 theta: 11, segno: 1,modifiedAngle: 4.72 theta: 11.2, segno: 1,modifiedAngle: 4.92 theta: 11.4, segno: 1,modifiedAngle: 5.12 theta: 11.6, segno: 1,modifiedAngle: 5.32 theta: 11.8, segno: 1,modifiedAngle: 5.52 theta: 12, segno: 1,modifiedAngle: 5.72 theta: 12.2, segno: 1,modifiedAngle: 5.92 theta: 12.4, segno: 1,modifiedAngle: 6.12 theta: 12.6, segno: 1,modifiedAngle: 0.04 theta: 12.8, segno: 1,modifiedAngle: 0.24 theta: 13, segno: 1,modifiedAngle: 0.44 theta: 13.2, segno: 1,modifiedAngle: 0.64 theta: 13.4, segno: 1,modifiedAngle: 0.84 theta: 13.6, segno: 1,modifiedAngle: 1.04 theta: 13.8, segno: 1,modifiedAngle: 1.24 theta: 14, segno: 1,modifiedAngle: 1.44 FINE Press any key to continue
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII Ultima modifica di vermaccio : 06-04-2006 alle 11:32. |
![]() |
![]() |
![]() |
#19 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
però ora.....
se ho numero >0 e >6.28 e scendo ho un salto:
theta: 13, segno: 1,modifiedAngle: 0.44 theta: 12.8, segno: 1,modifiedAngle: 0.24 theta: 12.6, segno: 1,modifiedAngle: 0.04 (salto da 0 a 6.28) theta: 12.4, segno: 1,modifiedAngle: 6.12 theta: 12.2, segno: 1,modifiedAngle: 5.92 idem per valori negativi dove salto da o a -6.28 caso I numero "theta" di partenza >0 ed aumentante: --------------------------------------------------- "modifiedAngle": se aumento appena supero 6.28 io torno a zero. 0 --> 6.28 -->--> 0 -> 6.28 -->... caso II numero "theta" di partenza <0 e diminuente: --------------------------------------------------- "modifiedAngle":se diminuisco e vado sotto -6.28 io torno a zero 0--> -6.28 -->--> 0 --> -6.28 --> ... questo è quello che fa il programma scritto, che contempla solo casi I e II però nel caso in cui ho casoIII numero "theta" di partenza >0 e diminuente: sino a quanto non diventa theta<0 (e finisco in caso II) --------------------------------------------------- "modifiedAngle":io ora vorrei fare in modo che se diminuisco arrivo a 0 invece di "saltare" cambio segno e diminuisco (sono passato a valori <0) cioè, per far capire, vorrei che le righe sopra diventassero heta: 13, segno: 1,modifiedAngle: 0.44 theta: 12.8, segno: 1,modifiedAngle: 0.24 theta: 12.6, segno: 1,modifiedAngle: 0.04 (non salto più a 6.28 ma cambio segno) theta: 12.4, segno: 1,modifiedAngle: -0.24 theta: 12.2, segno: 1,modifiedAngle: -0.44 cioè NON 6.28 --> 0 --> 6.28 -->... MA 6.28 --> 0 --> -0.1 --> -6.28 --> -6.28 -->... casoIV numero "theta" di partenza >0 e diminuente: sino a quanto non diventa theta<0 (e finisco in caso II) --------------------------------------------------- "modifiedAngle":io ora vorrei fare in modo che se aumento arrivo a 0 invece di "saltare" cambio segno e aumento (sono passato a valori >0) cioè NON -6.28 --> 0 --> -6.28 -->... MA -6.28 --> 0 --> 0.1 --> 6.28 --> 6.28 -->... conclusione desiderata: cioè mentre "theta" varia da +inf a -inf andando su e giù, attraversando magari più volte lo zero, l'angolo "modifiedAngle": se è positivo ed aumenta ogni volta che supera 6.28 salta e torna a zero e rinizia ad aumentare se negativo e diminuisce ogni volta che supera -6.28 salta e torna a zero e rinizia a diminuire MA se positivo e diminuisce, fino a quando theta >0, se arrivo a zero non salto a 6.28 a vado a numeri negativi se negativo e aumenta, fino a quando theta <0, se arrivo a zero non salto a -6.28 a vado a numeri positivi esempio(diminuiente) (theta)_(modifiedAngle) 8____1.72 (=8-6.28) 7____0.72 (=7-6.28) 6.29_0.01 (=6.29-6.28) 6.28_0 6.27_-0.01 (!!!) NON 6.27 (NO salto ma cambio segno) 5____-1.28 4____-2.28 2____-4.28 0.01_-6.27 0____0 (da qui come al solito) -0.01_-0.01 -2___-2 -4___-4 -5___-5 -6.28_-6.28 (salto) -6.29_-0.01 ... come posso fare?
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
#20 |
Senior Member
Iscritto dal: Sep 2001
Città: Roma
Messaggi: 2141
|
ecco un disegno per vedere al volo cosa vorrei fare
__________________
..strisc...strisc...oooooOOoooO ![]() http://digilander.iol.it/pentiumII Navi da battaglia giapponesi classe Yamato WWII |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:46.