#rotate vector function causes server to crash?
1 messages · Page 1 of 1 (latest)
private Vector rotate(Vector toRotate, Vector around, double angle) {
if (angle == 0.0) {
// line 133 V
return toRotate;
}
double vx = around.getX(), vy = around.getY(), vz = around.getZ();
double x = toRotate.getX(), y = toRotate.getY(), z = toRotate.getZ();
double sinA = Math.sin(Math.toRadians(angle)), cosA = Math.cos(Math.toRadians(angle));
double x1 = x * ((vx * vx) * (1 - cosA) + cosA) + y * ((vx * vy) * (1 - cosA) - vz * sinA) + z * ((vx * vz) * (1 - cosA) + vy * sinA);
double y1 = x * ((vy * vx) * (1 - cosA) + vz * sinA) + y * ((vy * vy) * (1 - cosA) + cosA) + z * ((vy * vz) * (1 - cosA) - vx * sinA);
double z1 = x * ((vz * vx) * (1 - cosA) - vy * sinA) + y * ((vz * vy) * (1 - cosA) + vx * sinA) + z * ((vz * vz) * (1 - cosA) + cosA);
return new Vector(x1, y1, z1);
}
what's line 113 and 51?
its the return statement
line 51 is where it calls the function which calls the rotate function
your for loop near line 113 never ends, or it's way too large
at 111?
when I remove line 100 it runs fine though it runs fine
hold on ill check
print out "min" and "max"
your rotate method probably does some weird stuff
and you are now looping over millions of blocks
the schematic im testing with's dimensions are (15.0, 26.0, 17.0)
print out the value of "min" and "max" before you go into the nested loop
print out the x y and z values in your inner loop, then check whether it only accesses the blocks you expect it to
that looks good so far
do you think that these sort of operations just requires more ram to run?
usually not, that's not many blocks
im pretty sure the nested for loops loop over all the blocks, and just checks if it's on the edge
unless you go for like 100k blocks, it should be fine (well it would cause lag, but shouldnt crash everything)
true
here ill show a particle at every spot it loops regardless of if it is on the edge or not
yeah it looks like the for is only looping over the region it should be
weird, sorry then I have no clue
maybe it isn't looping over the right area after the rotation
oh yeah
theres the issue
somehow after rotating it it becomes a recursive loop
never ends
yeah that's what I suspected
but what exactly causes it, idk
you'll have to debug it 😛 add tons of debug output
yeah so i dont think max is supposed to be (-2.4887484799999994E8, 6.2958062999999985E7, 2.1641046399999997E8)