Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zoom #69

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions api/parsers/ulgparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 11 additions & 7 deletions src/components/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 () => {
Expand Down Expand Up @@ -133,9 +140,6 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) {
}
select.style.maxHeight = "36px";

setTimeout(function () {
plotData.autoRange();
}, 200);
};

const stretchSelect = () => {
Expand Down Expand Up @@ -203,7 +207,7 @@ function Graph({ id, initialKeys, updateKeys, removeGraph }) {
spikecolor: "#000",
spikemode: "across+marker",
spikethickness: 1,
exponentformat: "e",
exponentformat: exponentData,
},
yaxis: {
exponentformat: "e",
Expand Down