Giter VIP home page Giter VIP logo

spinrate-visual's Introduction

Spinrate Visual

Made for this reddit post: https://www.reddit.com/r/Sabermetrics/comments/itmts8/how_are_baseballsavant_visualizations_made/

Most of this was auto generated by: https://threejs.org/editor/ The only actual coding I did was writing a small script to spin the ball (which is now located in app.json -> scripts):

// Pitch's rotation in radians per second
var spinRate = new THREE.Euler( 0.8, 0, -1.2, 'XYZ' );

function update( e ) {
	var deltaSeconds = e.delta / 1000;
	this.rotateX( spinRate.x * deltaSeconds )
	this.rotateY( spinRate.y * deltaSeconds )
	this.rotateZ( spinRate.z * deltaSeconds )
}

Alternatively if you only had spin axis and spin rate you could do something like this (untested and unimplemented):

// Pitch's axis of rotation (should probably be normalized)
var spinAxis = new THREE.Vector3( -0.4, 0, 0.6 );

// Pitch's rotational speed in radians per second
var spinRate = 2;

function update( e ) {
	var deltaSeconds = e.delta / 1000;
	this.rotateOnAxis( spinAxis, spinRate * deltaSeconds )
}

Using

  1. You can run this project as a web server and the index page will be a working animation.
  2. You can also import the app.json file into the threejs editor, I would reccomend this if you wanted to change the lighting / texture or anything like that
  3. If you don't like js and/or are transfering this to another language, take the above as psuedocode and create/find your own implementation. Here is a helpful explanation of rotating around an axis.

spinrate-visual's People

Contributors

vac1911 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.