hypar-io/Elements

Polyline.Frames inconsistent results

sanchez opened this issue · 4 comments

I was playing around with the Polyline.Frames function and noticed that the "normal" of the transform so to speak is not always point in the same direction. Here are some screenshots of what I have produced so far:

image

image

The idea is that the blue line represents the "normal" of the transform, which is just achieved by transforming a (0, 0, 1) vector.

Some additionally testing has shown that I seem to always get the "backwards" normals when the angle is accute:

image

To Reproduce

Polyline curve;
List<Element> items = new List<Element>();

Vector3 originPoint = new Vector3(0, 0, 0);
Vector3 pointingPoint = new Vector3(0, 0, 1);
Vector3 upPoint = new Vector3(1, 0, 0);
Vector3 sidePoint = new Vector3(0, 1, 0);

List<(Vector3 location, Vector3 direction, double magnitude, Color? color)> vectors = new List<(Vector3 location, Vector3 direction, double magnitude, Color? color)>();
Transform[] transforms = curve.Frames(0, 0);
foreach (Transform transform in transforms)
{
    Vector3 transformedOrigin = transform.OfPoint(originPoint);
    Vector3 transformedPointing = transform.OfPoint(pointingPoint);
    Vector3 transformedUp = transform.OfPoint(upPoint);
    Vector3 transformedSide = transform.OfPoint(sidePoint);

    vectors.Add((transformedOrigin, (transformedPointing - transformedOrigin), 2, Colors.Blue));
    vectors.Add((transformedOrigin, (transformedUp - transformedOrigin), 2, Colors.Red));
    vectors.Add((transformedOrigin, (transformedSide - transformedOrigin), 2, Colors.Green));
}

ModelArrows arrows = new ModelArrows(vectors);
items.Add(arrows);

return items;

Expected behavior
The blue lines/"normals" would all point along the curve in a similar direction?

Desktop (please complete the following information):

  • OS: Firefox, Windows 10

Thanks for reporting this, we'll look into it!

Also, just so you know, you can do Transform.ToModelCurves() to get r,g,b colored visualization of transform axes :)

This is fixed now, should go out with the next release (or the next alpha if you need it ASAP!)

Awesome, thanks so much