Solved Trig, cos,sin,tan. Info here

Discussion in 'Plugin Development' started by unforgiven5232, May 9, 2014.

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

    unforgiven5232

    I've been searching on Bukkit of different ways to position particles and players, and i always see somethings like
    Code:java
    1. Math.cos()
    2. Math.sin()
    3. Math.tan()

    But from my understanding that work like (opposite/hypotenuse) for sin i believe, but i don't understand how they work with java. Someone care to provide a quick explanation for this?
     
  2. Offline

    DxDy

    Those functions in java do for all of your purposes exactly the same they would do in mathematics. If you could narrow down your question, we'd propably be able to help you in more detail ;)
     
  3. Offline

    AoH_Ruthless

    unforgiven5232
    If you actually look at the methods, they require double parameters. The double parameter is an angle in radians.
     
    unforgiven5232 likes this.
  4. Offline

    unforgiven5232

    Radians? I've heard it before, just don't know it
     
  5. Offline

    DxDy

    In that case you won't be able to put those methods to much use without at least refreshing some elementary trigonometry.
     
    Windy Day and Konkz like this.
  6. Offline

    AoH_Ruthless

    unforgiven5232
    Radians are part of Circular Geometry (Unlike Triangle Geometry, which use degree formatting of angles).

    1 Radian is (180 / 2pi): Therefore there are 2 radians in one loop around a circle. Every 90 degrees adds 1/2pi to the measure. This is very basic: Go look up more info so you actually understand anything I just said.
     
    unforgiven5232 likes this.
  7. Offline

    unforgiven5232

    AoH_Ruthless You explained it very well, if I could, i would draw the picture to help show what you explained
     
    AoH_Ruthless likes this.
  8. Offline

    Windy Day

    Yea so the functions will return the sign/cos/tan value.
    Math.sin(double d); - return y value
    Math.cos(double d); - returns x value
    Math.tan(double d); - slope
    So Math.sin(Math.PI/2) would return 1. Because on the unit circle the y value at radian pi/2 is 1.
    Then, for example, you could add that and the players x and y to make a circle around them.
     
    unforgiven5232 likes this.
  9. Offline

    unforgiven5232

    Windy Day AoH_Ruthless Thanks for your help!

    Windy Day Hey also, would you mind explaining
    Code:java
    1. Math.toRadians(#)

    Please?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  10. Offline

    xTigerRebornx

  11. Offline

    unforgiven5232

  12. Offline

    SnipsRevival


    That is not exactly accurate.

    Every full loop around a circle (ie 360°) is equal to 2π radians instead of just 2 radians. Every half loop around a circle (ie 180°) is equal to π radians.

    If you have an angle ø, measured in degrees, the proper way to convert it to radians is ø*(π/180°). If you have an angle ø, measured in radians, the proper way to convert it to degrees is ø*(180°/π).
     
Thread Status:
Not open for further replies.

Share This Page