Java 类org.newdawn.slick.util.FastTrig 实例源码

项目:trashjam2017    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:trashjam2017    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:Progetto-C    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:Progetto-C    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:BaseClient    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:BaseClient    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:code404    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:GPVM    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:GPVM    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:GPVM    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:SpaceStationAlpha    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:SpaceStationAlpha    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:cretion    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:cretion    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:slick2d-maven    文件:RoundedRectangle.java   
/**
 * Generate the points to fill a corner arc.
 *
 * @param numberOfSegments How fine to make the ellipse.
 * @param radius The radius of the arc.
 * @param cx The x center of the arc.
 * @param cy The y center of the arc.
 * @param start The start angle of the arc.
 * @param end The end angle of the arc.
 * @return The points created.
 */
private List createPoints(int numberOfSegments, float radius, float cx, float cy, float start, float end) {
    ArrayList tempPoints = new ArrayList();

    int step = 360 / numberOfSegments;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius));

        tempPoints.add(new Float(x));
        tempPoints.add(new Float(y));
    }

    return tempPoints;
}
项目:slick2d-maven    文件:GraphicsTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    this.container = container;

    image = new Image("testdata/logo.tga", true);

    Image temp = new Image("testdata/palette_tool.png");
    container.setMouseCursor(temp, 0, 0);

    container.setIcons(new String[] {"testdata/icon.tga"});
    container.setTargetFrameRate(100);

    poly = new Polygon();
    float len = 100;

    for (int x=0;x<360;x+=30) {
        if (len == 100) {
            len = 50; 
        } else {
            len = 100;
        }
        poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, 
                      (float) FastTrig.sin(Math.toRadians(x)) * len);
    }
}
项目:trashjam2017    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:trashjam2017    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:Progetto-C    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:Progetto-C    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:BaseClient    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:BaseClient    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:code404    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:code404    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:fuzzy-octo-shame    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     *
     * @param theta The angle to calculate the components from (in degrees)
     */
    void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//        x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//                * (float) FastTrig.cos(StrictMath.toRadians(theta));
//        y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//                * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:fuzzy-octo-shame    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 *
 * @param x1
 *            The x coordinate of the top left corner of a box containing the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
void drawArc(float x1, float y1, float width, float height, int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x, y);
    }
    LSR.end();
    postdraw();
}
项目:GPVM    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:GPVM    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:GPVM    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:GPVM    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:SpaceStationAlpha    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:SpaceStationAlpha    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:cretion    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:cretion    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:slick2d-maven    文件:Vector2f.java   
/**
     * Calculate the components of the vectors based on a angle
     * 
     * @param theta The angle to calculate the components from (in degrees)
     */
    public void setTheta(double theta) {
        // Next lines are to prevent numbers like -1.8369701E-16
        // when working with negative numbers
        if ((theta < -360) || (theta > 360)) {
            theta = theta % 360;
        }
        if (theta < 0) {
            theta = 360 + theta;
        }
        double oldTheta = getTheta();
        if ((theta < -360) || (theta > 360)) {
            oldTheta = oldTheta % 360;
        }
        if (theta < 0) {
            oldTheta = 360 + oldTheta;
        }

        float len = length();
        x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
        y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));

//      x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.cos(StrictMath.toRadians(theta));
//      y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//              * (float) FastTrig.sin(StrictMath.toRadians(theta));
    }
项目:slick2d-maven    文件:Graphics.java   
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
        int segments, float start, float end) {
    predraw();
    TextureImpl.bindNone();
    currentColor.bind();

    while (end < start) {
        end += 360;
    }

    float cx = x1 + (width / 2.0f);
    float cy = y1 + (height / 2.0f);

    LSR.start();
    int step = 360 / segments;

    for (int a = (int) start; a < (int) (end + step); a += step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
        float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

        LSR.vertex(x,y);
    }
    LSR.end();
    postdraw();
}
项目:trashjam2017    文件:Ellipse.java   
/**
 * Generate the points to outline this ellipse.
 *
 */
protected void createPoints() {
    ArrayList tempPoints = new ArrayList();

    maxX = -Float.MIN_VALUE;
    maxY = -Float.MIN_VALUE;
    minX = Float.MAX_VALUE;
    minY = Float.MAX_VALUE;

    float start = 0;
    float end = 359;

    float cx = x + radius1;
    float cy = y + radius2;

    int step = 360 / segmentCount;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float newX = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius1));
        float newY = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius2));

        if(newX > maxX) {
            maxX = newX;
        }
        if(newY > maxY) {
            maxY = newY;
        }
        if(newX < minX) {
            minX = newX;
        }
        if(newY < minY) {
            minY = newY;
        }

        tempPoints.add(new Float(newX));
        tempPoints.add(new Float(newY));
    }
    points = new float[tempPoints.size()];
    for(int i=0;i<points.length;i++) {
        points[i] = ((Float)tempPoints.get(i)).floatValue();
    }
}
项目:Progetto-C    文件:Ellipse.java   
/**
 * Generate the points to outline this ellipse.
 *
 */
protected void createPoints() {
    ArrayList tempPoints = new ArrayList();

    maxX = -Float.MIN_VALUE;
    maxY = -Float.MIN_VALUE;
    minX = Float.MAX_VALUE;
    minY = Float.MAX_VALUE;

    float start = 0;
    float end = 359;

    float cx = x + radius1;
    float cy = y + radius2;

    int step = 360 / segmentCount;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float newX = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius1));
        float newY = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius2));

        if(newX > maxX) {
            maxX = newX;
        }
        if(newY > maxY) {
            maxY = newY;
        }
        if(newX < minX) {
            minX = newX;
        }
        if(newY < minY) {
            minY = newY;
        }

        tempPoints.add(new Float(newX));
        tempPoints.add(new Float(newY));
    }
    points = new float[tempPoints.size()];
    for(int i=0;i<points.length;i++) {
        points[i] = ((Float)tempPoints.get(i)).floatValue();
    }
}
项目:BaseClient    文件:Ellipse.java   
/**
 * Generate the points to outline this ellipse.
 *
 */
protected void createPoints() {
    ArrayList tempPoints = new ArrayList();

    maxX = -Float.MIN_VALUE;
    maxY = -Float.MIN_VALUE;
    minX = Float.MAX_VALUE;
    minY = Float.MAX_VALUE;

    float start = 0;
    float end = 359;

    float cx = x + radius1;
    float cy = y + radius2;

    int step = 360 / segmentCount;

    for (float a=start;a<=end+step;a+=step) {
        float ang = a;
        if (ang > end) {
            ang = end;
        }
        float newX = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius1));
        float newY = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius2));

        if(newX > maxX) {
            maxX = newX;
        }
        if(newY > maxY) {
            maxY = newY;
        }
        if(newX < minX) {
            minX = newX;
        }
        if(newY < minY) {
            minY = newY;
        }

        tempPoints.add(new Float(newX));
        tempPoints.add(new Float(newY));
    }
    points = new float[tempPoints.size()];
    for(int i=0;i<points.length;i++) {
        points[i] = ((Float)tempPoints.get(i)).floatValue();
    }
}
项目:opsu-dance    文件:Image.java   
/**
 * Unlike the other drawEmbedded methods, this allows for the embedded image
 * to be rotated. This is done by applying a rotation transform to each 
 * vertex of the image. This ignores getRotation but depends on the 
 * center x/y (scaled accordingly to the new width/height).
 * 
 * @param x the x to render the image at
 * @param y the y to render the image at
 * @param width the new width to render the image
 * @param height the new height to render the image
 * @param rotation the rotation to render the image, using getCenterOfRotationX/Y
 *
 * @author davedes
 */
public void drawEmbedded(float x, float y, float width, float height, float rotation) {
    if (rotation==0) {
        drawEmbedded(x, y, width, height);
        return;
    }
    init();
    float scaleX = width/this.width;
    float scaleY = height/this.height;

    float cx = getCenterOfRotationX()*scaleX;
    float cy = getCenterOfRotationY()*scaleY;

    float p1x = -cx;
    float p1y = -cy;
    float p2x = width - cx;
    float p2y = -cy;
    float p3x = width - cx;
    float p3y = height - cy;
    float p4x = -cx;
    float p4y = height - cy;

    double rad = Math.toRadians(rotation);
    final float cos = (float) FastTrig.cos(rad);
    final float sin = (float) FastTrig.sin(rad);

    float tx = getTextureOffsetX();
    float ty = getTextureOffsetY();
    float tw = getTextureWidth();
    float th = getTextureHeight();

    float x1 = (cos * p1x - sin * p1y) + cx; // TOP LEFT
    float y1 = (sin * p1x + cos * p1y) + cy;
    float x2 = (cos * p4x - sin * p4y) + cx; // BOTTOM LEFT
    float y2 = (sin * p4x + cos * p4y) + cy;
    float x3 = (cos * p3x - sin * p3y) + cx; // BOTTOM RIGHT
    float y3 = (sin * p3x + cos * p3y) + cy;
    float x4 = (cos * p2x - sin * p2y) + cx; // TOP RIGHT
    float y4 = (sin * p2x + cos * p2y) + cy;
    if (corners == null) {
        GL.glTexCoord2f(tx, ty);
        GL.glVertex3f(x+x1, y+y1, 0);
        GL.glTexCoord2f(tx, ty + th);
        GL.glVertex3f(x+x2, y+y2, 0);
        GL.glTexCoord2f(tx + tw, ty + th);
        GL.glVertex3f(x+x3, y+y3, 0);
        GL.glTexCoord2f(tx + tw, ty);
        GL.glVertex3f(x+x4, y+y4, 0);
    } else {
        corners[TOP_LEFT].bind();
        GL.glTexCoord2f(tx, ty);
        GL.glVertex3f(x+x1, y+y1, 0);
        corners[BOTTOM_LEFT].bind();
        GL.glTexCoord2f(tx, ty + th);
        GL.glVertex3f(x+x2, y+y2, 0);
        corners[BOTTOM_RIGHT].bind();
        GL.glTexCoord2f(tx + tw, ty + th);
        GL.glVertex3f(x+x3, y+y3, 0);
        corners[TOP_RIGHT].bind();
        GL.glTexCoord2f(tx + tw, ty);
        GL.glVertex3f(x+x4, y+y4, 0);
    }
}