- Home /
I'm trying to make an arc with vectrosity5,but i‘ve got some problems.
My aim
var segments = 15;
float ox = s.x + oi;
float oy = s.y + oj;
Vector3 o = new Vector3(ox, oy, s.z);
var linePoints = new List<Vector3>(segments + 1);
float sdegree = 0;
float edegree = 0;
var r = Mathf.Sqrt((s.x - o.x) * (s.x - o.x) + (s.y - o.y) * (s.y - o.y));
//startdegree
//0-90degree //Mathf.PI / 2 +* Mathf.Rad2Deg
if ((s.x - o.x >= 0) && (s.y - o.y > 0))
{
sdegree = (Mathf.Asin((s.x - o.x) / r)) * Mathf.Rad2Deg;
Debug.Log("1" + sdegree);
}
//90-180degree
if ((s.x - o.x > 0) && (s.y - o.y <= 0))
{
sdegree = (Mathf.PI / 2 + Mathf.Asin((o.y - s.y) / r)) * Mathf.Rad2Deg;
Debug.Log("2" + sdegree);
}
//180-270degree
if ((s.x - o.x <= 0) && (s.y - o.y < 0))
{
sdegree = (Mathf.PI + Mathf.Asin((o.x - s.x) / r)) * Mathf.Rad2Deg;
Debug.Log("3" + sdegree);
}
//270-0degree
if ((s.x - o.x < 0) && (s.y - o.y >= 0))
{
sdegree = (2 * Mathf.PI - Mathf.Asin((o.x - s.x) / r)) * Mathf.Rad2Deg;
Debug.Log("4" + sdegree);
}
//-----------------------enddegree-----------------------------------
//0-90degree
if ((e.x - o.x >= 0) && (e.y - o.y > 0))
{
edegree = (Mathf.Asin((e.x - o.x) / r)) * Mathf.Rad2Deg;
Debug.Log("1" + edegree);
Debug.Log(Mathf.Asin((e.x - o.x) / r));
}
//90-180degree
if ((e.x - o.x > 0) && (e.y - o.y <= 0))
{
edegree = (Mathf.PI / 2 + Mathf.Asin((o.y - e.y) / r)) * Mathf.Rad2Deg;
Debug.Log("2" + edegree);
}
//180-270degree
if ((e.x - o.x <= 0) && (e.y - o.y < 0))
{
edegree = (Mathf.PI + Mathf.Asin((o.x - e.x) / r)) * Mathf.Rad2Deg;
Debug.Log("3" + edegree);
}
//270-0degree
if ((e.x - o.x < 0) && (e.y - o.y >= 0))
{
edegree = (2 * Mathf.PI - Mathf.Asin((o.x - e.x) / r)) * Mathf.Rad2Deg;
Debug.Log("4" + edegree);
}
var line = new VectorLine("Line", linePoints, 0.1f, LineType.Continuous);
//var myLine = new VectorLine("Line", linePoints, 2f);
line.MakeArc(o, r, r, sdegree, edegree, segments);
line.Draw3D();
in unity
the vectrosity5 coding document: You can draw part of a circle or ellipse easily with this function. It’s very similar to $$anonymous$$akeEllipse, except you specify the start and end points of the arc in degrees. Also, the pointRotation parameter isn’t used with $$anonymous$$akeArc. myLine.$$anonymous$$akeArc (origin, up, xRadius, yRadius, startDegrees, endDegrees, segments, index); At the $$anonymous$$imum, you need to define the origin, radii, and the start and end degrees: myLine.$$anonymous$$akeArc (origin, xRadius, yRadius, startDegrees, endDegrees); As with $$anonymous$$akeCircle/$$anonymous$$akeEllipse, the up vector is only used with Vector3 points. If the segments parameter is left out, the arc uses all available points in the line. Along with segments, the index is useful for creating multiple arcs in the same VectorLine (which should use LineType.Discrete to avoid having all the arcs connected to each other). When used with Vector2 points, the degrees start at 0 at the top and go clockwise around the circle to 360. When used with Vector3 points, where the “top” is depends on the up vector and the camera orientation. If the supplied degrees go over 360, they wrap around, so for example 370° is the same as 10°. The same is true for negative numbers: -10° is the same as 350°. You can have the start degrees be greater than the end degrees, which is useful for defining which part of the circle is drawn in the case where you want to wrap around the top.
Your answer
Follow this Question
Related Questions
Vectrosity line smoothing issue. 0 Answers
Vectrocity error message 2 Answers
Drawing tiny objects (grid problem) 2 Answers
Vectrosity end caps Draw3D() 1 Answer
Asset not importing 1 Answer