JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function Vec4D() {
this.x = 0.0;
this.y = 0.0;
this.z = 0.0;
this.w = 0.0;
this.Add = function( t )
{
var ret = new Vec4D();
ret.x = this.x + t.x;
ret.y = this.y + t.y;
ret.z = this.z + t.z;
ret.w = this.w + t.w;
return ret;
}
this.Sub = function( t )
{
var ret = new Vec4D();
ret.x = this.x - t.x;
ret.y = this.y - t.y;
ret.z = this.z - t.z;
ret.w = this.w - t.w;
return ret;
}
this.Mul = function( t )
{
var ret = new Vec4D();
ret.x = this.x * t.x;
ret.y = this.y * t.y;
ret.z = this.z * t.z;
ret.w = this.w * t.w;
return ret;
}
this.MulScalar = function ( t )
{
var ret = new Vec4D();
ret.x = this.x * t;
ret.y = this.y * t;
ret.z = this.z * t;
ret.w = this.w * t;
return ret;
}
this.MulScalarSelf = function( t )
{
this.x *= t;
this.y *= t;
this.z *= t;
this.w *= t;
}
this.Div = function( t )
{
var ret = new Vec4D();
ret.x = this.x / t.x;
ret.y = this.y / t.y;
ret.z = this.z / t.z;
ret.w = this.w / t.w;
return ret;
}
this.DivScalar = function( t )
{
var ret = new Vec4D();
ret.x = this.x / t;
ret.y = this.y / t;
ret.z = this.z / t;
ret.w = this.w / t;
return ret;
}
this.DivScalarSelf = function( t )
{
this.x /= t;
this.y /= t;
this.z /= t;
this.w /= t;
}
this.Dot2D = function( t )
{
return this.x * t.x + this.y * t.y;
}
this.Dot4D = function( t )
{
return this.x * t.x + this.y * t.y + this.z * t.z + this.w * t.w;
}
this.Square2D = function()
{
return this.x * this.x + this.y * this.y;
}
this.Square4D = function()
{
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
}
this.Length2D = function()
{
return Math.sqrt( this.Square2D() );
}
this.Length4D = function()
{
return Math.sqrt( this.Square4D() );
}
this.Negate = function()
{
this.x = -this.x;
this.y = -this.y;
this.z = -this.z;
this.w =...