Solved Circle particle math help

Discussion in 'Plugin Development' started by HeavyMine13, Jan 18, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    HeavyMine13

  2. Offline

    mcdorli

    Instead of putting i straight to the Math.sin method, do Math.sin(Math.toRadians(i)), same with cosine
     
  3. Offline

    HeavyMine13

    Exactly what I did :p
     
  4. Offline

    ShowbizLocket61

  5. Offline

    ski23

  6. Offline

    ShowbizLocket61

    @ski23
    What we have been doing here is perpendicular to the player direction.
     
  7. Offline

    ski23

    On further review, I don't believe this would help me as this will only work for circles.
     
  8. Offline

    ShowbizLocket61

    @ski23
    Of course, any parametric function would suffice.
     
  9. Offline

    ski23

    Yes, but i need to be able to rotate any object in 3d not just a circle. ie a square
     
  10. Offline

    ShowbizLocket61

    @ski23
    You can rotate with the same way I used, but as for the square... that's not parametric, thus you'll have to do that one your own.
     
  11. Offline

    HeavyMine13

    Yes but only if the circle is to the +-Z axis. Doesn't work for x


    @ski23 LOL no, I didn't even see your post. I was trying to make a circle beam for a project :pPPP <3
     
  12. Offline

    ShowbizLocket61

    @HeavyMine13

    What do you mean, it doesn't work for x? It just goes in one direction, +Z?
     
  13. Offline

    HeavyMine13

    If you shoot it along the Z axis (both positive and negative) it will form a circle. If you try to shoot it along X axis or any other direction (other than z) it will form a disoriented circle(if its along the x axis, it will form a wide vertical line).. Weird O_O

    BTW Current code:
    Code:
        public void spawnCircle(Player player) {
            final Location location = player.getLocation();
            final double yaw = location.getYaw();
            final double[] time = {0.0};
            final double radius = 0.5;
            final double range = 30;
    
            new BukkitRunnable() {
                public void run() {
                    Vector vec = location.getDirection().multiply(time[0]);
                    Location center = new Location(location.getWorld(), location.getX() + vec.getX(), location.getY() + vec.getY(), location.getZ() + vec.getZ());
                    for (double i = 0; i < 360; i += 5) {
                        Location n = new Location(center.getWorld(), xPos(Math.toRadians(i), radius, yaw) + center.getX(), yPos(Math.toRadians(i), radius) + center.getY(), center.getZ());
                        ParticleEffect.REDSTONE.display(0, 0, 0, 0, 1, n, 8);
                    }
    
                    time[0] += 0.1;
                    if (time[0] >= range)
                        this.cancel();
                }
            }.runTaskTimer(this, 0, 1);
        }
    
     
  14. Offline

    ShowbizLocket61

    @HeavyMine13
    Make a zPos method, in which you multiply the radius and the sine of the yaw.
     
Thread Status:
Not open for further replies.

Share This Page