Skip to content

Instantly share code, notes, and snippets.

@kriskowal
Created February 17, 2018 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriskowal/f5ac642139f19d2b58486c043c3652ba to your computer and use it in GitHub Desktop.
Save kriskowal/f5ac642139f19d2b58486c043c3652ba to your computer and use it in GitHub Desktop.
var origin = entities[0].position;
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
entity.relativePosition.copyFrom(entity.position).subThis(origin);
entity.distance = entity.relativePosition.distance();
entity.direction = Math.atan2(entity.relativePosition.y, entity.relativePosition.x);
entity.distortion = res*Math.atan2(entity.distance, elevation)/Math.PI;
entity.projection.x = Math.cos(entity.direction) * entity.distortion;
entity.projection.y = Math.sin(entity.direction) * entity.distortion;
drawVessel(entity.projection.x, entity.projection.y, entity.orientation);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment