Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ideas for placing shapes around a circle
Message
De
23/05/2005 10:47:12
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
À
23/05/2005 10:26:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01015215
Message ID:
01016753
Vues:
9
This message has been marked as the solution to the initial question of the thread.
>Vorrei posizionare n oggetti equidistanto a parttire da questo punto.
>La cosa mi finziona solo pe un quadrante.

That's because you calculated the angle using sin() and cos() to retrieve the angle, and when calculating the angle from it you always take positive values.

My recommendation would be to calculate the angle as atan(y/x) - which would give you an angle between -pi/2 and +pi/2; if x negative you need to add one pi. And then stick to that angle and don't calculate it again. If x=0, you have pi/2 for positive y, and -pi/2 for negative.

And you are OK calculating the angle of one seat by dividing the seat size (assuming it's a circle) by circumference of your circle, then multiplying this with 2*pi.

I figure I don't need to remind you of what's the positive direction of an angle in trigonometry etc - you seem to have covered that.

>So che è una cavolata, lo so , ma la temperatura del mio povero cerebro mi impedisce un'altra oretta di prove !!!

C'mon... you're much more far north than we are. What do you think how hot is it in here?


>*- traccia una circonferenza ideale
>
>lCentrex = (this.width/2)
>lCentrey = (this.height/2)
>
>lRadius = Sqrt( (lcentrex - Mcol('',3) )^2 + (lcentrey - Mrow('',3))^2 )
>
>this.Circle(lradius,lcentrex,lcentrey)

This will give you length of a fifteenth of a circle with the given radius. If you want to know the number of the seats that can fit on a given circle, you need to divide by the seat's diameter, not 15.

>numero = Floor(2*pi()*lradius / 15)
>
>
>x = Mcol('',3)- lcentrex
>y = Mrow('',3)- lcentrey

Here we are, here you lose track of the quadrant. Sine(alfa) is positive for I and II quadrant, cos(alfa) is positive for I and IV quadrant.

>senalfa = y/lRadius
>cosalfa = Sqrt(1-senalfa^2)
>
>T = Sqrt( (1-cosalfa) / (1+cosalfa))

...and you were on good course here, except that you forgot that x and y are coordinates relative to your center, not relative to your .top and .left.

>*If y < lcentrey
>* t = -t
>*EndIf
>alfa = 2*Atan(t)
>*Do case
>* Case y > lcentrey
>* alfa = alfa + Dtor(180)
>
>* Case x < lcentrex and y < lcentrey
>* *--III quadrante
>* alfa = alfa + Dtor(90)
>* Case x < lcentrex and y > lcentrey
>* *--IV quadrante
>* alfa = alfa + Dtor(180)
>* Case x > lcentrex and y < lcentrey
>* *--II quadrante
>* alfa = alfa + Dtor(0)
>* Otherwise
>* alfa = alfa + Dtor(270)
>*
>*EndCase
> > >stepAngle = (2*PI()/numero)
>*=setposto(this,'c'+Alltrim(Str(Seconds())),(Mcol('',3)),(Mrow('',3)),15,15,0,40)
>
>For i = 0 to 5
>
> =setposto(this,'c'+Alltrim(Str(i))+Alltrim(Str(Seconds())), ;
> lradius*Cos(Dtor(Rtod(stepangle)* i + Rtod(alfa))) + lcentrex, ;
> lcentrey + lradius*Sin(Dtor(Rtod(stepangle)* i + Rtod(alfa))), ;
> 15,15,40,40)
>* lCentrex - lradius*COS(m.stepAngle*m.i), ;
>* m.lcentrey + lradius*SIN(stepAngle*m.i), ;
>* 15,15,40,40)
>
>EndFor

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform