# Particles

Comments in 'Plugin Development' started by Flabe, Jan 15, 2016.

1. Offline

### FlabeActive Member

Joined:
Nov 17, 2015
Posts:
147
Minecraft User:
Hello there friends!
I wanna ask you how to make an particle sphere?
2. Offline

### CraftYourBukkitNotable MemberPlugin Developer

Joined:
Jan 20, 2015
Posts:
1,022
Plugins:
2
Minecraft User:
Use the search bar.
applqpak and PEMapModder like this.
3. Offline

### FlabeActive Member

Joined:
Nov 17, 2015
Posts:
147
Minecraft User:
There is no answers on my question , all that I gat is the spiral , but I need SPHERE!
4. Offline

### minebuilder0110Notable Member

Joined:
Dec 8, 2014
Posts:
483
Minecraft User:
Not really sure if it is correct, but you would need to know the equation of a sphere ((x - a)^2 + (y - b)^2 + (z - c)^2 = r^2), and plot it with particles.
applqpak likes this.
5. Offline

### AndrewBitNotable Member

Joined:
Jun 18, 2015
Posts:
435
Minecraft User:
SOFe and applqpak like this.
6. Offline

### FlabeActive Member

Joined:
Nov 17, 2015
Posts:
147
Minecraft User:
THAT IS SPIRAL CODE I NEED SPHERE)))
7. Offline

### AndrewBitNotable Member

Joined:
Jun 18, 2015
Posts:
435
Minecraft User:
applqpak and Vaivez66 like this.
8. Offline

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,294
Plugins:
11
Minecraft User:
First of all, we need to know your parameters. For example, how do you specifiy the density of particles?
Remember, particles are points, and we are making an area, so density is definitely a concern.
I am not very good with spheres (I had never learnt anything about it except the formula of its surface area and volume, as well as definite integration for calculating volume of solid of revolution with equations of circles), so I am not sure how to provide parameters properly.
With my limited knowledge, I would consider using \$t, the number of dots per revolution. So, from a cross section from top view (assuming "north pole" is top and "south pole" is bottom), we will see longitudinal lines going vertically, and from a cross section from front view, we will see latitudinal lines running.
We will be drawing points on the intersecting points of the longitudinal and latitudinal lines.

PHP:
``` /*** @param Vector3 \$center the central point of the sphere* @param float \$radius the radius of the sphere* @param int \$t number of latitudinal lines. This can be a decimal number, but it will work strangely, won't it?* @param callable \$spawnParticle a callable that accepts three parameters: \$x, \$y, \$z. It is called per dotted point*/function(Vector3 \$center, \$radius, \$t, callable \$spawnParticle){    /**     * This is the angle formed by longitudinal lines from the top view.     * Use your imagination to think how it works with latitudinal lines.     *     * @var float \$delta     */    \$delta = M_PI * 2 / \$t;      // now, for every longitudinal line    // \$ry is the angle EOP, where O is center of sphere, E is the horizontal equator and P is one point on the longitudinal line    // M_PI_2 radian is 90 degrees    for(\$ry = -M_PI_2; \$ry < M_PI_2; \$ry += \$delta){        \$y = \$center->y + \$radius * sin(\$ry); // draw the picture yourself to understand why sin        /** @var float \$xz the radius of the longitudinal line's circle */        \$xz = \$radius * cos(\$ry);       // \$rh is the angle PO'P', where P and P' are points on the longitudinal line, and O' is the center of the longitudinal line's circle        for(\$rh = 0; \$rh < M_PI * 2; \$rh += \$delta){            \$x = \$center->x + \$xz * cos(\$rh);            \$z = \$center->z + \$xz * sin(\$rh);            \$spawnParticle(\$x, \$y, \$z);        }    }} ```
9. Offline

### FaigerSYSNew Member

Joined:
May 9, 2016
Posts:
8
This code not working for me((
10. Offline

### minebuilder0110Notable Member

Joined:
Dec 8, 2014
Posts:
483
Minecraft User:
Just saying that it is not working means nothing. Explain further.
11. Offline

### SOFeBanned

Joined:
May 28, 2016
Posts:
386
Minecraft User: