0

I am trying to create an equilateral triangle using three.js. What I am coming up with appears to be a bit too tall. I am defining my vertices like so:

new THREE.Vector3(0, 0, 0),
new THREE.Vector3(4, 0, 0),
new THREE.Vector3(2, 4, 0)

Here is a fiddle with what I have so far: http://jsfiddle.net/dkrotts/9d79ewff/. How can I modify this so I have a triangle with 3 equal sides?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Dustin
  • 8,217
  • 11
  • 33
  • 44
  • 1
    http://stackoverflow.com/questions/2861904/how-to-find-coordinates-of-a-2d-equilateral-triangle-in-c – Alex McMillan May 24 '15 at 04:58
  • 3
    I'm voting to close this question as off-topic because this is a problem of basic math, not a programming problem per se. You need to figure out how tall an equilateral triangle is relative to its sides (hint: use the Pythagorean theorem). – elixenide May 24 '15 at 04:58

1 Answers1

1

It looks a bit tall because it is. If you want each side to be length 4, the third vertex, the top one, isn't located at (2, 4, 0), it's located at (2, 3.4641, 0), 3.4641 being root 12.

drawTriangle(
  new THREE.Vector3(0, 0, 0),
  new THREE.Vector3(4, 0, 0),
  new THREE.Vector3(2, 3.4641, 0)
);

http://jsfiddle.net/9d79ewff/2/

lhoworko
  • 1,191
  • 2
  • 13
  • 24