126 |
126 |
return R*(sinAlpha-(float)Math.sin(x));
|
127 |
127 |
}
|
128 |
128 |
|
|
129 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
130 |
|
|
131 |
private float[] computeBands(float H, int alpha, float dist, float K, int N)
|
|
132 |
{
|
|
133 |
float[] bands = new float[2*N];
|
|
134 |
|
|
135 |
bands[0] = 1.0f;
|
|
136 |
bands[1] = 0.0f;
|
|
137 |
|
|
138 |
float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
|
|
139 |
float sinBeta = (float)Math.sin(beta);
|
|
140 |
float cosBeta = (float)Math.cos(beta);
|
|
141 |
float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
|
|
142 |
float D = R*sinBeta;
|
|
143 |
float B = h(R,sinBeta,K*beta);
|
|
144 |
|
|
145 |
if( D>1.0f )
|
|
146 |
{
|
|
147 |
for(int i=1; i<N; i++)
|
|
148 |
{
|
|
149 |
bands[2*i ] = (float)(N-1-i)/(N-1);
|
|
150 |
bands[2*i+1] = H*(1-bands[2*i]);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
else
|
|
154 |
{
|
|
155 |
int K2 = (int)((N-3)*K);
|
|
156 |
int K1 = (N-3)-K2;
|
|
157 |
|
|
158 |
for(int i=0; i<=K1; i++)
|
|
159 |
{
|
|
160 |
float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
|
|
161 |
float x = h(R,sinBeta,angle);
|
|
162 |
bands[2*i+2] = 1.0f - x;
|
|
163 |
bands[2*i+3] = g(R,D,x,cosBeta);
|
|
164 |
}
|
|
165 |
|
|
166 |
for(int i=0; i<=K2; i++)
|
|
167 |
{
|
|
168 |
float x = (1-B)*(i+1)/(K2+1) + B;
|
|
169 |
bands[2*K1+2 + 2*i+2] = 1.0f - x;
|
|
170 |
bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
|
|
171 |
}
|
|
172 |
}
|
|
173 |
|
|
174 |
bands[2*N-2] = 0.0f;
|
|
175 |
bands[2*N-1] = H;
|
|
176 |
|
|
177 |
return bands;
|
|
178 |
}
|
|
179 |
|
129 |
180 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130 |
181 |
|
131 |
182 |
private boolean areNotColinear(float[][] vertices, int index)
|
... | ... | |
947 |
998 |
" q=("+f.qx+", "+f.qy+", "+f.qz+", "+f.qw+") v=("+f.vx+", "+f.vy+", "+f.vz+")");
|
948 |
999 |
}
|
949 |
1000 |
|
950 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
951 |
|
|
952 |
|
private float[] computeBands(float H, int alpha, float dist, float K, int N)
|
953 |
|
{
|
954 |
|
float[] bands = new float[2*N];
|
955 |
|
|
956 |
|
bands[0] = 1.0f;
|
957 |
|
bands[1] = 0.0f;
|
958 |
|
|
959 |
|
float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
|
960 |
|
float sinBeta = (float)Math.sin(beta);
|
961 |
|
float cosBeta = (float)Math.cos(beta);
|
962 |
|
float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
|
963 |
|
float D = R*sinBeta;
|
964 |
|
float B = h(R,sinBeta,K*beta);
|
965 |
|
|
966 |
|
if( D>1.0f )
|
967 |
|
{
|
968 |
|
for(int i=1; i<N; i++)
|
969 |
|
{
|
970 |
|
bands[2*i ] = (float)(N-1-i)/(N-1);
|
971 |
|
bands[2*i+1] = H*(1-bands[2*i]);
|
972 |
|
}
|
973 |
|
}
|
974 |
|
else
|
975 |
|
{
|
976 |
|
int K2 = (int)((N-3)*K);
|
977 |
|
int K1 = (N-3)-K2;
|
978 |
|
|
979 |
|
for(int i=0; i<=K1; i++)
|
980 |
|
{
|
981 |
|
float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
|
982 |
|
float x = h(R,sinBeta,angle);
|
983 |
|
bands[2*i+2] = 1.0f - x;
|
984 |
|
bands[2*i+3] = g(R,D,x,cosBeta);
|
985 |
|
}
|
986 |
|
|
987 |
|
for(int i=0; i<=K2; i++)
|
988 |
|
{
|
989 |
|
float x = (1-B)*(i+1)/(K2+1) + B;
|
990 |
|
bands[2*K1+2 + 2*i+2] = 1.0f - x;
|
991 |
|
bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
|
992 |
|
}
|
993 |
|
}
|
994 |
|
|
995 |
|
bands[2*N-2] = 0.0f;
|
996 |
|
bands[2*N-1] = H;
|
997 |
|
|
998 |
|
return bands;
|
999 |
|
}
|
1000 |
|
|
1001 |
1001 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1002 |
1002 |
|
1003 |
1003 |
private void computeConvexityCenter(float[] out, float[] in, FaceTransform ft)
|
... | ... | |
1466 |
1466 |
float qz = fInfo.qz;
|
1467 |
1467 |
float qw = fInfo.qw;
|
1468 |
1468 |
|
1469 |
|
Static3D scale = new Static3D(sc,sc,sc);
|
|
1469 |
Static3D scale = new Static3D(sc,sc,1.0f);
|
1470 |
1470 |
Static3D move3D= new Static3D(vx,vy,vz);
|
1471 |
1471 |
Static4D quat = new Static4D(qx,qy,qz,qw);
|
1472 |
1472 |
|
very important bugfix in FactoryCubit.createRoundedSolid: now the roundness of the external face and its max height is independent of the size of the cubie.