user6612690
user6612690

Reputation:

SVG - Calculating angle direction inside triangle

I'm trying to draw a triangle and his angles on svg, my problem is that I don't know how to 'decide' the angle direction. They should point to the center to the triangle and not the other way.

Take a look at this example.

https://jsfiddle.net/ybaruchel/tdovywm0/

For now I just hard-coded it in these lines:

/** Calculating the direction of the angle **/
var x_arc_dir = 1;
var y_arc_dir = 1;
var z_arc_dir = 1;

Thanks in advance!

Upvotes: 1

Views: 458

Answers (1)

Gerardo Furtado
Gerardo Furtado

Reputation: 102184

Just swap the start and end angles:

var y_arc_end_x = (x1 - y1) - (x1 / 1.5) + parseInt(y1 * 1.67);
var y_arc_start_x   = (z1 - y1) - (z1 / 1.5) + parseInt(y1 * 1.67);

var y_arc_end_y = (x2 - y2) - (x2 / 1.5) + parseInt(y2 * 1.67);
var y_arc_start_y   = (z2 - y2) - (z2 / 1.5) + parseInt(y2 * 1.67);

Here is your fiddle: https://jsfiddle.net/rouzrtpt/

Upvotes: 1

Related Questions