// Vector Calulator

function VectorCalculator(f1, f2, angle){
	this.f1 = f1; // vector 1
	this.f2 = f2; // vector 2
	this.angle = angle; // angle between vector 1 and 2
	this.fr; // resulting vector
	this.alpha; // angle between vector 1 and resulting vector
	this.beta; // angle between vector 2 and resulting vector
}

// returns resulting vector
VectorCalculator.prototype.resultingVector = function(){
	this.fr = Math.pow(Math.pow(this.f1,2) + Math.pow(this.f2, 2) - (2 * this.f1 * this.f2 * Math.cos((180 - this.angle) * Math.PI / 180)), 0.5);
	var a1 = this.f1 * Math.sin((180 - this.angle) * Math.PI / 180) / this.fr;
	this.alpha = Math.asin(a1) * 180 / Math.PI;
	var a2 = this.f2 * Math.sin((180 - this.angle) * Math.PI / 180) / this.fr;
	this.beta = Math.asin(a2) * 180 / Math.PI;
	return this.fr;
}

// returns alpha angle
VectorCalculator.prototype.alphaAngle = function(){
	return this.alpha; 
}

// returns beta angle
VectorCalculator.prototype.betaAngle = function(){
	return this.beta;
}

// Copyright engineeringtoolbox.com
