/**
       创建一个五角星形状.
       该五角星的中心坐标为(sx,sy),中心到顶点的距离为radius,其中某个顶点与中心的连线的偏移角度为theta(弧度)
       @return pentacle 一个☆
    */
    public static Shape createPentacle(double sx,double sy,double radius,double theta){
        final double arc = Math.PI/5;
        final double rad = Math.sin(Math.PI/10)/Math.sin(3*Math.PI/10);
        GeneralPath path = new GeneralPath();
        path.moveTo(1,0);
        for(int idx = 0;idx < 5;idx ++){
            path.lineTo(rad*Math.cos((1+2*idx)*arc),rad*Math.sin((1+2*idx)*arc));
            path.lineTo(Math.cos(2*(idx+1)*arc),Math.sin(2*(idx+1)*arc));
        }
        path.closePath();
        AffineTransform atf = AffineTransform.getScaleInstance(radius,radius);
        atf.translate(sx/radius,sy/radius);
        atf.rotate(theta);
        return atf.createTransformedShape(path);
    }如上代码所示,数学功底不好凸显了,很苦恼,求帮助。

解决方案 »

  1.   

    创建一个五角星形状.
      该五角星的中心坐标为(sx,sy),中心到顶点的距离为radius,其中某个顶点与中心的连线的偏移角度为theta(弧度)
    说的这么清楚了还不明白吗?
    LZ应该是语文功底不好吧.......汗.
    一个点,确定了五角星的中心位置
    距离确定了五角星的大小
    偏移角度确定了五角星的方向
      

  2.   

    我是说 
      final double arc = Math.PI/5;
      final double rad = Math.sin(Math.PI/10)/Math.sin(3*Math.PI/10);
      GeneralPath path = new GeneralPath();
      path.moveTo(1,0);
      for(int idx = 0;idx < 5;idx ++){
      path.lineTo(rad*Math.cos((1+2*idx)*arc),rad*Math.sin((1+2*idx)*arc));
      path.lineTo(Math.cos(2*(idx+1)*arc),Math.sin(2*(idx+1)*arc));
      }
    这段的含义。