function solve_cx(anglx,sidec)
{
// convert degrees to radians
anglexinradians = anglx * Math.PI / 180
// solve for side a
sidea = Math.sin(anglexinradians) * sidec;
// solve for side b
sideb = Math.cos(anglexinradians) * sidec;
var sides = { a:sidea, b:sideb };
return sides;
}
var v = solve_cx(30,300);
// the position of object in world
var x = 200;
var y = 200;
// we already know the starting point so log that
$('.point_a').css({left: x + 'px', top: y +'px'});
$('.point_a').attr('data-coords', x + ', ' + y );
// now we take starting point and add the left of v.b to get other end of straigth line
$('.point_b').css({left: parseInt(x+v.b) + 'px', top: y +'px'});
$('.point_b').attr('data-coords', parseInt(x+v.b) + ', ' + y );
$('.point_c').css({left: parseInt(x+v.b) + 'px', top: parseInt(y-v.a) +'px'});
$('.point_c').attr('data-coords', parseInt(x+v.b) + ', ' + parseInt(y-v.a) );
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.