Ejemplo n.º 1
0
        public static Duct Transform(this Duct duct, TransformMatrix transform, double tolerance = Tolerance.Distance)
        {
            if (!transform.IsRigidTransformation(tolerance))
            {
                BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported.");
                return(null);
            }

            Duct result = duct.ShallowClone();

            result.StartPoint = result.StartPoint.Transform(transform);
            result.EndPoint   = result.EndPoint.Transform(transform);

            Vector normalBefore = new Line {
                Start = duct.StartPoint, End = duct.EndPoint
            }.ElementNormal(duct.OrientationAngle);
            Vector normalAfter = normalBefore.Transform(transform);

            result.OrientationAngle = normalAfter.OrientationAngleLinear(new Line {
                Start = result.StartPoint, End = result.EndPoint
            });

            return(result);
        }