0

This one has me stumped.

I've got code to draw ellipses etc in Unity. It all works great. But at the moment I only get horizontal ellipses or vertical ellipses by changing the major and minor axes.

What I really need is to be able to draw ellipses at angle, tilted, skewiff, NOT straight up or sideways.

Please help. Even better if it can be done using standard draw ellipse code.

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
Philip
  • 43
  • 2
  • 7

1 Answers1

0

I don't know how do you draw ellipses because you haven't post any code but this is how you can calculate points on tilted ellipse

var resolution = 50; //resolution of ellipse
var a = 50;
var b = 20;
var rotation = Quaternion.Euler(45,0,0); //set your angles here
for(var i = 0f; i < 2*Mathf.PI; i+=2*Mathf.PI/resolution){
    var vector = new Vector3( a*Mathf.Cos(i) ,0, b*Mathf.Sin(i) );
    vector = rotation*vector; // you can multiply vector by quaternion to get tilted ellipse

    //you can do something with vector here

}
Peter G
  • 155
  • 1
  • 8
  • Thank you for the help. var rotation = Quaternion.Euler(45,0,0); //set your angles here vector = rotation*vector; That's what I needed. – Philip Sep 06 '15 at 21:38