diff --git a/api/parsers/ulgparser.py b/api/parsers/ulgparser.py index cb5551a..40de1bf 100644 --- a/api/parsers/ulgparser.py +++ b/api/parsers/ulgparser.py @@ -16,21 +16,19 @@ def euler_from_quaternion(self, w, x, y, z): angles = {} #roll(x-axis rotation) - sinr_cosp = 2 * (w * x + y * z); - cosr_cosp = 1 - 2 * (x * x + y * y); - angles['roll'] = math.atan2(sinr_cosp, cosr_cosp); + sinr_cosp = 2 * (w * x + y * z) + cosr_cosp = 1 - 2 * (x * x + y * y) + angles['roll'] = math.atan2(sinr_cosp, cosr_cosp) #pitch (y-axis rotation) - sinp = 2 * (w * y - z * x); - if (abs(sinp) >= 1): - angles['pitch'] = math.copysign(math.pi / 2, sinp); # use 90 degrees if out of range - else: - angles['pitch'] = math.asin(sinp); + sinp = math.sqrt(1+2*(w*y - x*z)) + cosp = math.sqrt(1-2*(w*y - x*z)) + angles['pitch'] = 2*math.atan2(sinp,cosp) - math.pi/2 # yaw (z-axis rotation) - siny_cosp = 2 * (w * z + x * y); - cosy_cosp = 1 - 2 * (y * y + z * z); - angles['yaw'] = math.atan2(siny_cosp, cosy_cosp); + siny_cosp = 2 * (w * z + x * y) + cosy_cosp = 1 - 2 * (y * y + z * z) + angles['yaw'] = math.atan2(siny_cosp, cosy_cosp) return angles diff --git a/src/components/Graph.js b/src/components/Graph.js index e97ac5b..c683414 100644 --- a/src/components/Graph.js +++ b/src/components/Graph.js @@ -10,6 +10,7 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { const [selectedOptions, setSelectedOptions] = useState([]); const [inputValue, setInputValue] = useState(""); const [data, setData] = useState([]); + const [exponentData, setExponentData] = useState("none"); useEffect(() => { getInitialData(); @@ -21,10 +22,16 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { }, []); useEffect(() => { - setTimeout(function () { - plotData.autoRange(); - }, 200); // eslint-disable-next-line + const max_x = Math.max(...data.map(xarray=>{ + return xarray.x[xarray.x.length-1]; + })); + if(max_x>1e5){ + setExponentData("e"); + } + else{ + setExponentData("none"); + } }, [data]); const getInitialData = async () => { @@ -133,9 +140,6 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { } select.style.maxHeight = "36px"; - setTimeout(function () { - plotData.autoRange(); - }, 200); }; const stretchSelect = () => { @@ -203,7 +207,7 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) { spikecolor: "#000", spikemode: "across+marker", spikethickness: 1, - exponentformat: "e", + exponentformat: exponentData, }, yaxis: { exponentformat: "e",