# SnippetvCircles

#### Dirac

##### 22710180
vCircles is a very useful snippet for spinning points around bidimensional cicles or tridimensional spheres. It's very fast and has the capacity of calculating distances across the circle's perimeter, so if you want to move a projectile for, lets say, 40 units around a perimeter, with vCircles you can.
JASS:
``````library vCircles
//**************************************************************************************************************************
//Snippet made by Dirac to avoid polar offset positioning
//  This creates a circle around a point with a base angle 0. this angle determines the offset location
//  of the point you might need to move or create something.

//Variables:
//  real x
//      -center X
//  real y
//      -center Y
//  real xyangle
//      -current angle in the x axis
//  real zangle
//      -current angle in the z axis

//  real offsetX
//      -the X depending on the circle's radius and current angle
//  real offsetY
//      -the Y depending on the circle's radius and current angle
//  real offsetZ
//      -the Z depending on the circle's height.
//  real xyspin
//      -the amount of spins done in the x axis.
//  real zspin
//      -the amount of spins done in the z axis.

//Setting up values
//      -Sets the xyangle base rotation to a value

//Methods:
//  static method create takes real x, real y, real z, real radius returns thistype
//          -Imput here the center x,y,z and radius, default angle is 0, you can change that later

//          -This method reduces or increases the radius lenght towards an angle
//          -The angle is measured starting from the edge of the circle, a few examples:
//            if the angle provided is 0 the radius would increase exactly by the amount provided,
//            if the angle provided is 180 the radius would decrease exactly by the amount provided,
//            if the angle provided is 90 the radius would increase sightly

//  method polarVector2d takes real howMuch, boolean clockwise returns nothing
//          -This method moves the circle angle around it's radius depending on the amount provided
//          -This is a very good way to avoid polar offset when you wan't to move something exactly
//          by an amount of distance around a point, not an angle.

//  method polarVector3d takes real howMuch, real radians returns nothing
//          -This method moves the offset of the point by the amount provided towards the angle
//          provided around the sphere. Use this if you care about the distance the point moves

//          -This method spins the offset of the point around the X and Z axis towards the angle
//          provided. Use this to give a smooth movement around the circle.

//**************************************************************************************************************************
struct circle
real x
real y
real z
real xyangle
real zangle

private real xBase

static method create takes real x, real y,real z, real radius returns thistype
local thistype this=thistype.allocate()
set .x=x
set .y=y
set .z=z
set .xyangle=0
set .zangle=0
set .xyspin=0
set .zspin=0
set .xBase=0
return this
endmethod

method operator baseX= takes real radians returns nothing
endmethod

method operator offsetZ takes nothing returns real
endmethod

method operator offsetX takes nothing returns real
endmethod

method operator offsetY takes nothing returns real
endmethod

endmethod

method polarVector2d takes real howMuch, boolean clockwise returns nothing
if clockwise==false then
set .xyangle=.xyangle+a
else
set .xyangle=.xyangle-a
endif
set .xyspin=.xyspin+a
endmethod

method polarVector3d takes real howMuch, real radians returns nothing
set .xyangle=.xyangle+a
set .zangle=.zangle+b
set .xyspin=.xyspin+a
set .zspin=.zspin+b
endmethod

endmethod

endstruct
endlibrary``````

Graphical explanations of how to use it coming soon. Enjoy!

#### Attachments

• 59.4 KB Views: 307

#### Nestharus

##### o-o
You know, it'd be cooler if you had an x radius, y radius, and z radius, or you allowed for horizontal and vertical eccentricity. This upgrade this resource from supporting just circles and spheres to ellipses and ellipsoids.

Another cool thing would be to be able to base the x,y coords off of a widget or location =P.

#### Dirac

##### 22710180
Well i tried to add the Y radius before, but didn't get the math though. Ellipses would be very cool yes, but i feel i'm not skilled enought to do it yet, i'll keep working on that. (So far the only thing i can do is add the Z ellipse option that would be very easy)

#### Dirac

##### 22710180

General chit-chat
Help Users
• No one is chatting at the moment.

### Members online

No members online now.