java.lang.Math#sin ( )源码实例Demo

下面列出了java.lang.Math#sin ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GiantTrees   文件: Transformation.java
public Transformation rotaxis(double angle,Vector axis) {
	// rotation about an axis
	angle = angle*Math.PI/180;
	axis=axis.normalize();
	double a = axis.getX();
	double b = axis.getY();
	double c = axis.getZ();
	double si = Math.sin(angle);
	double co = Math.cos(angle);
	
	Matrix rm = new Matrix(
			(co+a*a*(1-co)),(-c*si+b*a*(1-co)),(b*si+c*a*(1-co)),
			(c*si+a*b*(1-co)),(co+b*b*(1-co)),(-a*si+c*b*(1-co)),
			(-b*si+a*c*(1-co)),(a*si+b*c*(1-co)),(co+c*c*(1-co)));
	return new Transformation(rm.prod(matrix),vector);
}
 
源代码2 项目: Llunatic   文件: Exp.java
public Object exp(Object param)
	throws ParseException
{
	if (param instanceof Complex)
	{
	  	Complex z = (Complex) param;
	  	double x = z.re();
	  	double y = z.im();
	  	double mod = Math.exp(x);
		return new Complex(mod*Math.cos(y),mod*Math.sin(y));
	}
	else if (param instanceof Number) 
	{
		return new Double(Math.exp(((Number)param).doubleValue()));
	}

	throw new ParseException("Invalid parameter type");
}
 
源代码3 项目: GiantTrees   文件: Transformation.java
public Transformation rotaxisz(double delta, double rho) {
	// local rotation away from the local z-axis 
	// about an angle delta using an axis given by rho 
	// - used for splitting and random rotations
	delta = delta*Math.PI/180;
	rho = rho*Math.PI/180;
	
	double a = Math.cos(rho);
	double b = Math.sin(rho);
	double si = Math.sin(delta);
	double co = Math.cos(delta);
	
	Matrix rm = new Matrix((co+a*a*(1-co)),(b*a*(1-co)),(b*si),
			(a*b*(1-co)),(co+b*b*(1-co)),(-a*si),
			(-b*si),(a*si),(co));
	return new Transformation(matrix.prod(rm),vector);
}
 
源代码4 项目: KEEL   文件: GA_Tun.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
private double ValorNormal(double desv) {
    double u1, u2;

    /* we generate 2 uniform values [0,1] */
    u1 = Randomize.Rand();
    u2 = Randomize.Rand();

    /* we calcules a normal value with the uniform values */
    return (desv * Math.sqrt( -2 * Math.log(u1)) *
            Math.sin(2 * Math.PI * u2));
}
 
源代码5 项目: KEEL   文件: AG.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
private double ValorNormal (double desv) {
	double u1, u2;

	/* we generate 2 uniform values [0,1] */
	u1 = Randomize.Rand ();
	u2 = Randomize.Rand ();

	/* we calcules a normal value with the uniform values */
	return (desv * Math.sqrt (-2 * Math.log(u1)) * Math.sin (2*Math.PI*u2));
}
 
源代码6 项目: KEEL   文件: Est_evol.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
private double ValorNormal (double desv) {
	double u1, u2;

	/* we generate 2 uniform values [0,1] */
	u1=Randomize.Rand ();
	u2=Randomize.Rand ();

	/* we calcules a normal value with the uniform values */
	return (desv * Math.sqrt (-2 * Math.log(u1)) * Math.sin (2*Math.PI*u2));
}
 
源代码7 项目: KEEL   文件: Est_evol_M2TSK.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
private double ValorNormal (double desv) {
	double u1, u2;

	/* we generate 2 uniform values [0,1] */
	u1=Randomize.Rand ();
	u2=Randomize.Rand ();

	/* we calcules a normal value with the uniform values */
	return (desv * Math.sqrt (-2.0 * Math.log(u1)) * Math.sin (2.0*PI*u2));
}
 
源代码8 项目: KEEL   文件: AG_Tun.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
private double ValorNormal(double desv) {
  double u1, u2;

  /* we generate 2 uniform values [0,1] */
  u1 = Randomize.Rand();
  u2 = Randomize.Rand();

  /* we calcules a normal value with the uniform values */
  return (desv * Math.sqrt( -2 * Math.log(u1)) * Math.sin(2 * PI * u2));
}
 
源代码9 项目: KEEL   文件: Est_evol.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
public double ValorNormal(double desv) {
    double u1, u2;

    /* we generate 2 uniform values [0,1] */
    u1 = Randomize.Rand();
    u2 = Randomize.Rand();

    /* we calcules a normal value with the uniform values */
    return (desv * Math.sqrt( -2.0 * Math.log(u1)) * Math.sin(2.0 * PI * u2));
}
 
源代码10 项目: KEEL   文件: Est_evol.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
public double ValorNormal(double desv) {
    double u1, u2;

    /* we generate 2 uniform values [0,1] */
    u1 = Randomize.Rand();
    u2 = Randomize.Rand();

    /* we calcules a normal value with the uniform values */
    return (desv * Math.sqrt( -2.0 * Math.log(u1)) * Math.sin(2.0 * Math.PI * u2));
}
 
源代码11 项目: KEEL   文件: Est_evol.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
public double ValorNormal(double desv) {
  double u1, u2;

  /* we generate 2 uniform values [0,1] */
  u1 = Randomize.Rand();
  u2 = Randomize.Rand();

  /* we calcules a normal value with the uniform values */
  return (desv * Math.sqrt( -2 * Math.log(u1)) * Math.sin(2 * PI * u2));
}
 
源代码12 项目: KEEL   文件: Est_mu_landa.java
/** Generates a normal value with hope 0 and tipical deviation "desv */
private double ValorNormal(double desv) {
  double u1, u2;

  /* we generate 2 uniform values [0,1] */
  u1 = Randomize.Rand();
  u2 = Randomize.Rand();

  /* we calcules a normal value with the uniform values */
  return (desv * Math.sqrt( -2 * Math.log(u1)) * Math.sin(2 * PI * u2));
}
 
源代码13 项目: Llunatic   文件: Sine.java
public Object sin(Object param)
	throws ParseException
{
	if (param instanceof Complex) {
		return ((Complex)param).sin();
	}
	else if (param instanceof Number) {
		return new Double(Math.sin(((Number)param).doubleValue()));
	}
	
	throw new ParseException("Invalid parameter type");
}
 
源代码14 项目: GiantTrees   文件: Transformation.java
public Transformation rotz(double angle) {
	// local rotation about z-axis
	angle = angle*Math.PI/180;
	Matrix rm = new Matrix(Math.cos(angle),-Math.sin(angle),0,
			Math.sin(angle),Math.cos(angle),0,
			0,0,1);
	return new Transformation(matrix.prod(rm),vector);
}
 
源代码15 项目: ure   文件: ULight.java
float intensityFlickerPulse(int time) {
    float i = (float)Math.sin((double)time * 0.05);
    return i;
}
 
源代码16 项目: ure   文件: ULight.java
float intensityFlickerCompulse(int time) {
    float i = (float)Math.sin((double)time*0.05) + (float)Math.sin((double)time*0.03);
    return i;
}
 
源代码17 项目: KEEL   文件: Est_evol.java
private void Mutacion () {
	int n_hijo, i, j, nq, n1, n2;
	double z0, z1, x1, x2, si, co;

	for (n_hijo=0; n_hijo<Landa; n_hijo++) {
		/* Mutation of sigma */
		if (n_sigma==1)  /* if we use only a sigma, the sigma is adapted with Tau_1 */
			Hijos[n_hijo].Gene[tabla.n_variables] *= ValorNormal (Tau_1);
		else {
			z0 = ValorNormal (Tau_0);
			for (i=tabla.n_variables; i<tabla.n_variables + n_sigma; i++) {
				z1 = ValorNormal (Tau);
				Hijos[n_hijo].Gene[i] *= Math.exp (z1+z0);

				/* The standard desviation is Epsilon_sigma if it becomes 0 */
				if (Hijos[n_hijo].Gene[i]==0.0)
					Hijos[n_hijo].Gene[i] = Epsilon_sigma;
			}
		}  
      
		/* Mutation of alfa */
		for (i = tabla.n_variables + n_sigma; i<tabla.n_variables + n_sigma + n_alfa; i++) {
			z0 = ValorNormal (Beta);
			Hijos[n_hijo].Gene[i] += z0;

			/* Si el valor mutado se sale del intervalo [-i,i], se proyecta
			circularmente el valor a dicho intervalo */
			if (Math.abs(Hijos[n_hijo].Gene[i])>i)
				Hijos[n_hijo].Gene[i] -= 2 *i * signo (Hijos[n_hijo].Gene[i]);
		}

		/* Mutation of x */
  
		/* we calculate the uncorrelated vector of mutations */
		for (i=0; i<tabla.n_variables; i++)
			if (tabla.n_variables + i < tabla.n_variables + n_sigma)
				Z[i] = ValorNormal (Hijos[n_hijo].Gene[tabla.n_variables+i]);
			else /* if there aren't more tipical desviations we use the latest */
				Z[i] = ValorNormal (Hijos[n_hijo].Gene[tabla.n_variables+n_sigma-1]);      
   
		/* Correlation of the vector if we use the angles */  
		if (n_alfa!=0) {
			nq = n_alfa;
			for (j=nl_alfa; j<=nm_alfa; ++j) {
				n1 = tabla.n_variables - j;
				n2 = tabla.n_variables;
				for (i=1; i<=j; ++i) {
					x1 = Z[n1-1];
					x2 = Z[n2-1];
					si = Math.sin(Hijos[n_hijo].Gene[tabla.n_variables + n_sigma + nq - 1]);
					co = Math.cos(Hijos[n_hijo].Gene[tabla.n_variables + n_sigma + nq - 1]);
					Z[n2-1] = x1*si + x2*co;
					Z[n1-1] = x1*co - x2*si;
					--n2;
					--nq;
				}
			} 
		}
   
		/* Final mutation of X */ 
		for (i=0; i<tabla.n_variables; i++) {
			Hijos[n_hijo].Gene[i] += Z[i];	

			if (Hijos[n_hijo].Gene[i] < -(Math.PI/2.0))
				Hijos[n_hijo].Gene[i] = -(Math.PI/2.0) + 1E-10;
			if (Hijos[n_hijo].Gene[i] > (Math.PI/2.0))
				Hijos[n_hijo].Gene[i] = (Math.PI/2.0) - 1E-10;
		}
	}
}
 
源代码18 项目: KEEL   文件: Est_evol_M2TSK.java
private void Mutacion () {
	int n_hijo, i, j, nq, n1, n2;
	double z0, z1, x1, x2, si, co;

	for (n_hijo=0; n_hijo<Landa; n_hijo++) {
		/* Mutation of sigma */
		if (n_sigma==1)  /* if we use only a sigma, the sigma is adapted with Tau_1 */
			Hijos[n_hijo].Gene[tabla.n_variables] *= ValorNormal (Tau_1);
		else {
			z0 = ValorNormal (Tau_0);
			for (i=tabla.n_variables; i < tabla.n_variables + n_sigma; i++) {
				z1 = ValorNormal (Tau);
				Hijos[n_hijo].Gene[i] *= Math.exp (z1+z0);

				/* The standard desviation is Epsilon_sigma if it becomes 0 */
				if (Hijos[n_hijo].Gene[i]==0.0)
					Hijos[n_hijo].Gene[i] = Epsilon_sigma;
			}
		}

		/* Mutation of alfa */
		for (i = tabla.n_variables + n_sigma; i<tabla.n_variables + n_sigma + n_alfa; i++) {
			z0 = ValorNormal (Beta);
			Hijos[n_hijo].Gene[i] += z0;

			/* Si el valor mutado se sale del intervalo [-i,i], se proyecta
			circularmente el valor a dicho intervalo */
			if (Math.abs(Hijos[n_hijo].Gene[i])>i)  Hijos[n_hijo].Gene[i] -= 2.0 * PI * signo (Hijos[n_hijo].Gene[i]);
		}

		/* Mutation of x */

		/* we calculate the uncorrelated vector of mutations */
		for (i=0; i<tabla.n_variables; i++) {
			if (tabla.n_variables + i < tabla.n_variables + n_sigma)  Z[i] = ValorNormal (Hijos[n_hijo].Gene[tabla.n_variables+i]);
			else  Z[i] = ValorNormal (Hijos[n_hijo].Gene[tabla.n_variables+n_sigma-1]); /* if there aren't more tipical desviations we use the latest */
		}
				

		/* Correlation of the vector if we use the angles */
		if (n_alfa!=0) {
			nq = n_alfa;
			for (j=nl_alfa; j<=nm_alfa; ++j) {
				n1 = tabla.n_variables - j;
				n2 = tabla.n_variables;
				for (i=1; i<=j; ++i) {
					x1 = Z[n1-1];
					x2 = Z[n2-1];
					si = Math.sin(Hijos[n_hijo].Gene[tabla.n_variables + n_sigma + nq - 1]);
					co = Math.cos(Hijos[n_hijo].Gene[tabla.n_variables + n_sigma + nq - 1]);
					Z[n2-1] = x1*si + x2*co;
					Z[n1-1] = x1*co - x2*si;
					--n2;
					--nq;
				}
			}
		}

		/* Final mutation of X */
		for (i=0; i<tabla.n_variables; i++) {
			Hijos[n_hijo].Gene[i] += Z[i];

			if (Hijos[n_hijo].Gene[i] < (-1.0 * (PI/2.0)))  Hijos[n_hijo].Gene[i] = (-1.0 * (PI/2.0)) + 1E-10;
			if (Hijos[n_hijo].Gene[i] > (PI/2.0))  Hijos[n_hijo].Gene[i] = (PI/2.0) - 1E-10;
		}
	}
}
 
源代码19 项目: KEEL   文件: Est_mu_landa.java
private void Mutacion() {
  int n_hijo, i, j, nq, n1, n2;
  double z0, z1, x1, x2, si, co;

  for (n_hijo = 0; n_hijo < Landa; n_hijo++) {
    /* Mutation of sigma */
    if (n_sigma == 1)
        /* if we use only a sigma, the sigma is adapted with Tau_1 */
         {
      Hijos[n_hijo].Gene[tabla.n_variables] *= ValorNormal(Tau_1);
    }
    else {
      z0 = ValorNormal(Tau_0);
      for (i = tabla.n_variables; i < tabla.n_variables + n_sigma; i++) {
        z1 = ValorNormal(Tau);
        Hijos[n_hijo].Gene[i] *= Math.exp(z1 + z0);

        /* The standard desviation is Epsilon_sigma if it becomes 0 */
        if (Hijos[n_hijo].Gene[i] == 0.0) {
          Hijos[n_hijo].Gene[i] = Epsilon_sigma;
        }
      }
    }

    /* Mutation of alfa */
    for (i = tabla.n_variables + n_sigma;
         i < tabla.n_variables + n_sigma + n_alfa; i++) {
      z0 = ValorNormal(Beta);
      Hijos[n_hijo].Gene[i] += z0;

      /* Si el valor mutado se sale del intervalo [-i,i], se proyecta
           circularmente el valor a dicho intervalo */
      if (Math.abs(Hijos[n_hijo].Gene[i]) > i) {
        Hijos[n_hijo].Gene[i] -= 2 * PI * signo(Hijos[n_hijo].Gene[i]);
      }
    }

    /* Mutation of x */

    /* we calculate the uncorrelated vector of mutations */
    for (i = 0; i < tabla.n_variables; i++) {
      if (tabla.n_variables + i < tabla.n_variables + n_sigma) {
        Z[i] = ValorNormal(Hijos[n_hijo].Gene[tabla.n_variables + i]);
      }
      else
      /* if there aren't more tipical desviations we use the latest */
      {
        Z[i] = ValorNormal(Hijos[n_hijo].Gene[tabla.n_variables + n_sigma - 1]);
      }
    }

    /* Correlation of the vector if we use the angles */
    if (n_alfa != 0) {
      nq = n_alfa;
      for (j = nl_alfa; j <= nm_alfa; ++j) {
        n1 = tabla.n_variables - j;
        n2 = tabla.n_variables;
        for (i = 1; i <= j; ++i) {
          x1 = Z[n1 - 1];
          x2 = Z[n2 - 1];
          si = Math.sin(Hijos[n_hijo].Gene[tabla.n_variables + n_sigma + nq -
                        1]);
          co = Math.cos(Hijos[n_hijo].Gene[tabla.n_variables + n_sigma + nq -
                        1]);
          Z[n2 - 1] = x1 * si + x2 * co;
          Z[n1 - 1] = x1 * co - x2 * si;
          --n2;
          --nq;
        }
      }
    }

    /* Final mutation of X */
    for (i = 0; i < tabla.n_variables; i++) {
      Hijos[n_hijo].Gene[i] += Z[i];

      if (Hijos[n_hijo].Gene[i] < - (PI / 2.0)) {
        Hijos[n_hijo].Gene[i] = - (PI / 2.0) + 1E-10;
      }
      if (Hijos[n_hijo].Gene[i] > (PI / 2.0)) {
        Hijos[n_hijo].Gene[i] = (PI / 2.0) - 1E-10;
      }
    }
  }
}
 
源代码20 项目: incubator-retired-mrql   文件: SystemFunctions.java
public static MR_double sin ( MR_double x ) { return new MR_double(Math.sin(x.get())); }