Java Code Examples for java.lang.Math#sin()
The following examples show how to use
java.lang.Math#sin() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Transformation.java From GiantTrees with GNU General Public License v3.0 | 6 votes |
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); }
Example 2
Source File: Exp.java From Llunatic with GNU General Public License v3.0 | 6 votes |
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"); }
Example 3
Source File: Transformation.java From GiantTrees with GNU General Public License v3.0 | 6 votes |
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); }
Example 4
Source File: Est_evol.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 5
Source File: Transformation.java From GiantTrees with GNU General Public License v3.0 | 5 votes |
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); }
Example 6
Source File: Sine.java From Llunatic with GNU General Public License v3.0 | 5 votes |
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"); }
Example 7
Source File: Est_mu_landa.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 8
Source File: Est_evol.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 9
Source File: Est_evol.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 10
Source File: AG_Tun.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 11
Source File: Est_evol_M2TSK.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 12
Source File: Est_evol.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 13
Source File: AG.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 14
Source File: GA_Tun.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example 15
Source File: Est_evol_M2TSK.java From KEEL with GNU General Public License v3.0 | 4 votes |
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; } } }
Example 16
Source File: Est_evol.java From KEEL with GNU General Public License v3.0 | 4 votes |
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; } } }
Example 17
Source File: Est_mu_landa.java From KEEL with GNU General Public License v3.0 | 4 votes |
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; } } } }
Example 18
Source File: ULight.java From ure with MIT License | 4 votes |
float intensityFlickerCompulse(int time) { float i = (float)Math.sin((double)time*0.05) + (float)Math.sin((double)time*0.03); return i; }
Example 19
Source File: ULight.java From ure with MIT License | 4 votes |
float intensityFlickerPulse(int time) { float i = (float)Math.sin((double)time * 0.05); return i; }
Example 20
Source File: SystemFunctions.java From incubator-retired-mrql with Apache License 2.0 | votes |
public static MR_double sin ( MR_double x ) { return new MR_double(Math.sin(x.get())); }