Normalizing the amounts of steering in mobile app

parent 64d623d7
......@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def project do
[app: :grains,
version: "0.0.78",
version: "0.0.79",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
......
......@@ -93,7 +93,7 @@ let OrientationPanel = {
shape.setAttribute('transform','translate(' + (x) + ', ' + (y) + ')');
that.send_value([pitch, roll]);
that.send_value([x, y]);
}
}).start();
......@@ -117,18 +117,22 @@ let OrientationPanel = {
send_value(values) {
values[0] = (((values[0] - 0.25) / 0.75) - 0.5) * 2; // scale to normal movement range
values[1] = Math.pow((values[1] - 0.5), 3) * 8; // prefer larger amounts
// values[0] = (((values[0] - 0.25) / 0.75) - 0.5) * 2; // scale to normal movement range
// values[1] = Math.pow((values[1] - 0.5), 3) * 8; // prefer larger amounts
// console.log(values);
let scaled = values.map(function(i) {
// scale to +/- Pi to one decimal
// scale to +/- Pi to one decimal
i = (i/100.0) - 0.5;
// i = Math.pow(i, 3);
return Math.round(20 * i * Math.PI) / 10; // parseInt(i * 127);
});
// console.log(scaled);
if (!_.isEqual(scaled, this.old_values)) {
// console.log(scaled);
let payload = {pitch: scaled[0],
roll: scaled[1]
let payload = {pitch: scaled[1],
roll: scaled[0]
};
this.orientationChannel.push("orientation", payload)
.receive("error", e => console.log(e));
this.old_values = scaled;
......
......@@ -111,10 +111,10 @@ Boid.prototype.render = function() {
// Wraparound
Boid.prototype.borders = function() {
if (this.position.x < -this.radius) this.position.x = width +this.radius;
if (this.position.y < -this.radius) this.position.y = height+this.radius;
if (this.position.x > width +this.radius) this.position.x = -this.radius;
if (this.position.y > height+this.radius) this.position.y = -this.radius;
if (this.position.x < -this.radius) this.position.x = PresenceSketch.width +this.radius;
if (this.position.y < -this.radius) this.position.y = PresenceSketch.height+this.radius;
if (this.position.x > PresenceSketch.width +this.radius) this.position.x = -this.radius;
if (this.position.y > PresenceSketch.height+this.radius) this.position.y = -this.radius;
// if (this.position.x < this.radius) this.velocity.x = -this.velocity.x;
......@@ -127,7 +127,7 @@ Boid.prototype.borders = function() {
// Method checks for nearby boids and steers away
Boid.prototype.separate = function(boids) {
let that = this;
var desiredseparation = 50.0;
var desiredseparation = 70.0;
var steer = this.p.createVector(0, 0);
var count = 0;
// For every boid in the system, check if it's too close
......
<h1>Play</h1>
P: <span id="pitch"></span><br/>
R: <span id="roll"></span>
<div id="svg-container">
<%= if assigns[:user_type] == 1 do %>
<svg xmlns="http://www.w3.org/2000/svg"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment