mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 15:00:48 +00:00
use generalized spiral points algorithm
This commit is contained in:
parent
c0c083d62e
commit
5c08de449c
@ -29,6 +29,11 @@ public class ExplosionNukeRay {
|
|||||||
|
|
||||||
private double overrideRange = 0;
|
private double overrideRange = 0;
|
||||||
|
|
||||||
|
int gss_num_max;
|
||||||
|
int gss_num;
|
||||||
|
double gss_x;
|
||||||
|
double gss_y;
|
||||||
|
|
||||||
public ExplosionNukeRay(World world, int x, int y, int z, int strength, int count, int speed, int length) {
|
public ExplosionNukeRay(World world, int x, int y, int z, int strength, int count, int speed, int length) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.posX = x;
|
this.posX = x;
|
||||||
@ -46,6 +51,39 @@ public class ExplosionNukeRay {
|
|||||||
|
|
||||||
//starts at around 80, becomes 8 at length 500
|
//starts at around 80, becomes 8 at length 500
|
||||||
this.overrideRange = Math.max((Math.log(length) * 4 - 2.5D) * 10, 0);
|
this.overrideRange = Math.max((Math.log(length) * 4 - 2.5D) * 10, 0);
|
||||||
|
|
||||||
|
// Total number of points
|
||||||
|
this.gss_num_max = (int)(2.5 * Math.PI * Math.pow(this.strength,2));
|
||||||
|
this.gss_num = 1;
|
||||||
|
|
||||||
|
// The beginning of the generalized spiral points
|
||||||
|
this.gss_x = Math.PI;
|
||||||
|
this.gss_y = 0.0;
|
||||||
|
|
||||||
|
}
|
||||||
|
// Raise one generalized spiral points
|
||||||
|
private void generateGssUp(){
|
||||||
|
if (this.gss_num < this.gss_num_max) {
|
||||||
|
int k = this.gss_num + 1;
|
||||||
|
double hk = -1.0 + 2.0 * (k - 1.0) / (this.gss_num_max - 1.0);
|
||||||
|
this.gss_x = Math.acos(hk);
|
||||||
|
|
||||||
|
double prev_lon = this.gss_y;
|
||||||
|
double lon = prev_lon + 3.6 / Math.sqrt(this.gss_num_max) / Math.sqrt(1.0 - hk * hk);
|
||||||
|
this.gss_y = lon % (Math.PI * 2);
|
||||||
|
} else {
|
||||||
|
this.gss_x = 0.0;
|
||||||
|
this.gss_y = 0.0;
|
||||||
|
}
|
||||||
|
this.gss_num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Cartesian coordinates for spherical coordinates
|
||||||
|
private Vec3 getSpherical2cartesian(){
|
||||||
|
double dx = Math.sin(this.gss_x) * Math.cos(this.gss_y);
|
||||||
|
double dz = Math.sin(this.gss_x) * Math.sin(this.gss_y);
|
||||||
|
double dy = Math.cos(this.gss_x);
|
||||||
|
return Vec3.createVectorHelper(dx, dy, dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void processBunch(int count) {
|
/*public void processBunch(int count) {
|
||||||
@ -334,40 +372,12 @@ public class ExplosionNukeRay {
|
|||||||
|
|
||||||
int amountProcessed = 0;
|
int amountProcessed = 0;
|
||||||
|
|
||||||
double bow = Math.PI * this.strength;
|
while (this.gss_num_max >= this.gss_num){
|
||||||
double bowCount = Math.ceil(bow);
|
// 一般化螺旋集合を 一個上げる
|
||||||
|
this.generateGssUp();
|
||||||
|
|
||||||
//Axial
|
//球面座標を直交座標を取得
|
||||||
//StartY starts at this.length
|
Vec3 vec = this.getSpherical2cartesian();
|
||||||
for(int v = startY; v <= bowCount; v++) {
|
|
||||||
|
|
||||||
float part = (float) (Math.PI/bow);
|
|
||||||
float rot = part * -v;
|
|
||||||
|
|
||||||
Vec3 heightVec = Vec3.createVectorHelper(0, -strength, 0);
|
|
||||||
heightVec.rotateAroundZ(rot);
|
|
||||||
|
|
||||||
double y = heightVec.yCoord;
|
|
||||||
|
|
||||||
double sectionRad = Math.sqrt(Math.pow(strength, 2) - Math.pow(y, 2));
|
|
||||||
double circumference = 2 * Math.PI * sectionRad;
|
|
||||||
|
|
||||||
//if(y < 2 && y > -2)
|
|
||||||
// circumference *= 1.25D;
|
|
||||||
|
|
||||||
//circumference = Math.ceil(circumference);
|
|
||||||
|
|
||||||
//Radial
|
|
||||||
//StartCir starts at circumference
|
|
||||||
for(int r = startCir; r < circumference; r ++) {
|
|
||||||
|
|
||||||
Vec3 vec = Vec3.createVectorHelper(sectionRad, y, 0);
|
|
||||||
vec = vec.normalize();
|
|
||||||
/*if(y > 0)
|
|
||||||
vec.rotateAroundZ((float) (y / sectionRad) * 0.15F);*/
|
|
||||||
/*if(y < 0)
|
|
||||||
vec.rotateAroundZ((float) (y / sectionRad) * 0.15F);*/
|
|
||||||
vec.rotateAroundY((float) (360 / circumference * r));
|
|
||||||
|
|
||||||
int length = (int)Math.ceil(strength);
|
int length = (int)Math.ceil(strength);
|
||||||
|
|
||||||
@ -403,17 +413,11 @@ public class ExplosionNukeRay {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
amountProcessed++;
|
amountProcessed++;
|
||||||
|
|
||||||
if(amountProcessed >= count) {
|
if(amountProcessed >= count) {
|
||||||
startY = v;
|
|
||||||
startCir = startCir + 1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
isAusf3Complete = true;
|
isAusf3Complete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user