fixed zoom to fit
This commit is contained in:
parent
1e3efe5150
commit
4f1dfae696
@ -193,7 +193,8 @@ export class Display {
|
|||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
|
||||||
// Draw arrow for the velocity
|
// Draw arrow for the velocity
|
||||||
if (this.sim.getOption('show.velocity')) {
|
if (this.sim.getOption('display.velocity')) {
|
||||||
|
console.log('velocity vector');
|
||||||
const speed = Math.sqrt(vx ** 2 + vy ** 2);
|
const speed = Math.sqrt(vx ** 2 + vy ** 2);
|
||||||
const endVx = x + VELOCITY_VECTOR_SCALE * vx / speed * Math.log(speed);
|
const endVx = x + VELOCITY_VECTOR_SCALE * vx / speed * Math.log(speed);
|
||||||
const endVy = y + VELOCITY_VECTOR_SCALE * vy / speed * Math.log(speed);
|
const endVy = y + VELOCITY_VECTOR_SCALE * vy / speed * Math.log(speed);
|
||||||
@ -209,7 +210,7 @@ export class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw arrow for acceleration
|
// Draw arrow for acceleration
|
||||||
if (this.sim.getOption('show.acceleration')) {
|
if (this.sim.getOption('display.acceleration')) {
|
||||||
const accelerationMagnitude = Math.sqrt(acceleration.x ** 2 + acceleration.y ** 2);
|
const accelerationMagnitude = Math.sqrt(acceleration.x ** 2 + acceleration.y ** 2);
|
||||||
const endAx = x + ACCELERATION_VECTOR_SCALE * acceleration.x /
|
const endAx = x + ACCELERATION_VECTOR_SCALE * acceleration.x /
|
||||||
accelerationMagnitude * Math.log(accelerationMagnitude);
|
accelerationMagnitude * Math.log(accelerationMagnitude);
|
||||||
|
|||||||
@ -49,7 +49,6 @@ export class Zoom extends Tool {
|
|||||||
const biggerRatio = Math.max(widthRatio, heightRatio);
|
const biggerRatio = Math.max(widthRatio, heightRatio);
|
||||||
const base2factor = Math.log(1/biggerRatio) / Math.log(2);
|
const base2factor = Math.log(1/biggerRatio) / Math.log(2);
|
||||||
const factor = Math.floor(base2factor) - 1;
|
const factor = Math.floor(base2factor) - 1;
|
||||||
console.log({biggerRatio, base2factor, factor});
|
|
||||||
this.sim.scheduleZoom({x, y}, factor);
|
this.sim.scheduleZoom({x, y}, factor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user