Skip to content
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
9 changes: 3 additions & 6 deletions js/models/Airplane.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.Airplane = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
integrationStep(this, ['x', 'vx', 'y', 'vy', 'pitch', 'pitch_rate', 'elevator_angle', 'throttle', 'brake'], 0.02);
}

Expand Down
9 changes: 3 additions & 6 deletions js/models/BlockOnSlope.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.BlockOnSlope = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
}

Models.BlockOnSlope.prototype.vars =
Expand Down
11 changes: 4 additions & 7 deletions js/models/BouncingBallPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.BouncingBallPlatform = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
}

Models.BouncingBallPlatform.prototype.vars =
Expand Down Expand Up @@ -326,4 +323,4 @@ Models.BouncingBallPlatform.prototype.infoText = function ()
+ "\nhinge.angle = " + this.hinge_angle.toFixed(2).padStart(6,' ')
+ "\nhinge.speed = " + this.hinge_angular_speed.toFixed(2).padStart(6,' ')
+ "\nT = " + this.T.toFixed(2).padStart(6,' ');
}
}
9 changes: 3 additions & 6 deletions js/models/CruiseControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.CruiseControl = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
}

Models.CruiseControl.prototype.vars =
Expand Down
9 changes: 3 additions & 6 deletions js/models/DoublePendulum.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.DoublePendulum = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
}

Models.DoublePendulum.prototype.vars =
Expand Down
9 changes: 3 additions & 6 deletions js/models/Multirotor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.Multirotor = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
}

Models.Multirotor.prototype.vars =
Expand Down
9 changes: 3 additions & 6 deletions js/models/RocketLanding.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.RocketLanding = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
}

Models.RocketLanding.prototype.vars =
Expand Down
9 changes: 3 additions & 6 deletions js/models/SinglePendulum.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.SinglePendulum = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
}

Models.SinglePendulum.prototype.vars =
Expand Down
22 changes: 9 additions & 13 deletions js/models/Vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ if (typeof Models === 'undefined') var Models = {};

Models.Vehicle = function(params)
{
var nVars = Object.keys(this.vars).length;
for(var i = 0; i < nVars; i++)
{
var key = Object.keys(this.vars)[i];
this[key] = (typeof params[key] == 'undefined')?this.vars[key]:params[key];
}
Object.keys(this.vars).forEach(key => {
this[key] = (typeof params[key] === 'undefined') ? this.vars[key] : params[key];
});
this.updateLidarPoints();
}

Expand Down Expand Up @@ -38,12 +35,11 @@ Models.Vehicle.prototype.vars =

Models.Vehicle.prototype.updateLidarPoints = function ()
{
this.lidarPoints = [];
for (var i = 0; i < this.lidarDirections.length; i++) {
var lidarPoint = this.lineSearch(this.x,this.y,this.heading + this.lidarDirections[i]);
lidarPoint.direction = this.lidarDirections[i];
this.lidarPoints.push(lidarPoint);
};
this.lidarPoints = this.lidarDirections.map(direction => {
const lidarPoint = this.lineSearch(this.x, this.y, this.heading + direction);
lidarPoint.direction = direction;
return lidarPoint;
});
}

Models.Vehicle.prototype.simulate = function (dt, controlFunc)
Expand Down Expand Up @@ -205,4 +201,4 @@ Models.Vehicle.prototype.infoText = function ()
str += "\n/* Simulation time */ vehicle.T = " + round(this.T,2);

return str;
}
}