0 Members and 1 Guest are viewing this topic.
Pt-On(RCos(Z),Rsin(Z
so for example something like this? (TI-BASIC)9->X9->YClrDrawWhile 1For(Z,0,359Pt-On(X*cos(Z)-y*sin(Z),X*sin(Z)-y*cos(ZEndEndright?(Altough this example appears to be kinda buggy... the first time the dot is displayed at the highest top value it can be as well as the farthest to the right )
ZSquareClrDrawFor(Z,0,359Pt-On(5cos(Z)+5sin(Z),5sin(Z)-5cos(ZEnd
ZSquareClrDrawFor(Z,0,359Pt-On(5cos(Z),5sin(ZEnd
[8000000000000000->Pic19->x->Y0->Zrepeat getkey(15)Z+90Sub(S)->DZSub(S)->EPt-On(5*D+30,5*E+30,Pic1Z+1->ZDispGraphEndReturnLbl S->A^64/16->BA^16->AIf B^216-A->AEndA-(A*A*A/600->AIf B/2^2-A->AEndAReturn
[8000000000000000->Pic19->x->Y0->Zrepeat getkey(15)16-ZSub(S)->DZSub(S)->EPt-On(5*D+30,5*E+30,Pic1Z+1->ZDispGraphEndReturnLbl S->A^64/16->BA^16->AIf B^216-A->AEndA-(A*A*A/600->AIf B/2^2-A->AEndAReturn
A-(A*A*A/600->A
A-(A*A*A/600)->A
Sin_A:;input a in pi/256 radians from [0,pi);output l is a binary value in the range [0,1);destroys h,de;a is unmodified;Will West ld h,a ld e,h call HtimesE;hl=x^2 ex de,hl;x^2 ld l,a ld h,0 or a;reset carry sbc hl,de add hl,hl add hl,hl ret HtimesE: ld l,0 ld d,0 sla h ; optimised 1st iteration jr nc,$+3 ld l,e add hl,hl ;1 jr nc,$+3 ; add hl,de ; add hl,hl ;2 jr nc,$+3 ; add hl,de ; add hl,hl ;3 jr nc,$+3 ; add hl,de ; add hl,hl ;4 jr nc,$+3 ; add hl,de ; add hl,hl ;5 jr nc,$+3 ; add hl,de ; add hl,hl ;6 jr nc,$+3 ; add hl,de ; add hl,hl ;7 jr nc,$+3 ; add hl,de ; ret ;;=================================================================================;;does sin(a) where a is between (-pi,pi) and is in units of ;;128/pi radians;;inputs a;;outputs a;;destroys bc,de,hl;;=================================================================================Sin_A_Signed: bit 7,a jr z,Sin_A_Signed2 neg sla a call Sin_A ld a,l neg retSin_A_Signed2: sla a call Sin_A ld a,l ret
That looks almost right.The Pt-On line should look like this: Look here↓Pt-On(X*cos(Z)+Y*sin(Z),X*sin(Z)-Y*cos(ZAnd, it can be optimized to this as well:Pt-On(Xcos(Z)+Ysin(Z),Xsin(Z)-Ycos(Z // Removed "*" tokensKeep in mind that it rotates around the origin, or the 0, 0 point. Also, you can keep adding 1 to Z, and it will still work. Z does not have to be between 0 and 360, 361 will rotate it 1 degree.