[ORD CE 10.10 C#] Bug? DTransform3d.FromRotationAroundLine

Hi,

I have code that makes use of the DTransform3d.FromRotationAroundLine method. In previous versions this worked as expected but in the latest release of the SDK this does not seem to work, the rotation origin defaults to 0,0,0 regardless of what is passed into the FromRotationAroundLine method. 

Has anyone else come across this issue?

Cheers

Matt

  • Hello <Mathew,

    Could you post a code snippet showing the issue and perhaps a screenshot from a debug session showing the variables?

    Thanks,

    Chris

  • Hi Chris,

    I have tried to give you as much info as possible. The rotation about point does not seem to have any effect on the resulting rotation, the profile is always rotated around 0,0,0 regardless of where the rotate about point is located. I am 99 percent sure this was working in previous versions.

    //rotate vehicle for cant
                ////////////////////////////////////////////
    
                double angleRadians = Math.Tan(vehicleAlignmentPoint.CantTuple.Item2 / SelectedCant.CenterToCenter);
                Angle cantAngle = new Angle();
                double halfCentreCentre = Helpers.GeometryHelper.MeterstoUOR(SelectedCant.CenterToCenter / 2);
                if (vehicleAlignmentPoint.CantTuple.Item1 == 0 || vehicleAlignmentPoint.CantTuple.Item1 == 2)
                {
                    //left hand cant is greater
                    cantAngle = Angle.FromRadians(-angleRadians);
                    halfCentreCentre = halfCentreCentre * -1;
                }
                else
                {
                    //right hand cant is greater
                    cantAngle = Angle.FromRadians(-angleRadians);
                }
    
                DVector3d rotationLineVector = new DVector3d(halfCentreCentre, 0, 0);
    
                DPoint3d rotateAbout = new DPoint3d(0, halfCentreCentre, 0);
    
                DTransform3d cantTransform = new DTransform3d();
                cantTransform = DTransform3d.FromRotationAroundLine(rotateAbout, rotationLineVector, cantAngle);
    
                DMatrix3d cantRotationMatrix = new DMatrix3d(cantTransform);

    Thanks

    Matt

  • Hi Matthew,

    I’ve tested it in version 10.10.20.048 of the SDK and I couldn’t find any issue with DTransform3d.FromRotationAroundLine method. 

    The code below uses the method to rotate a vertical line(cyan) [starting at (32.5, 20, 15) and ending at (32.5,20,35)] around another line(red) [starting at(5,10,10) and ending at (60,30,35)] by positive 90 degrees (the two lines are not perpendicular respect to each other). 
    The resulting line(magenta) is [(27.59668,25.55589,21.34259)-(40.67220,10.74019,24.42901)]

    I've used an arbitrary line as rotating axis but using X axis (1,0,0) or Y axis(0,1,0) or Z axis(0,0,1) the method works fine as well.

    public void RotationTest()
    	{
    	//Line where trasnform will be applied
    	DSegment3d segment = new DSegment3d(32.5 * _uorPerMeter, 20 * _uorPerMeter, 15 * _uorPerMeter, 32.5 * _uorPerMeter, 20 * _uorPerMeter, 35 * _uorPerMeter);
    	LineElement lineToRotate = new LineElement(_dgnModel, null, segment);
    
    	//Line representing an arbitrary axis 
    	DSegment3d lineToRotateAround = new DSegment3d(5 * _uorPerMeter, 10 * _uorPerMeter, 10 * _uorPerMeter, 60 * _uorPerMeter, 30 * _uorPerMeter, 35 * _uorPerMeter);
    	LineElement axisLine = new LineElement(_dgnModel, null, lineToRotateAround);
    
    	//Get the vector representing lineToRotateAround
    	DVector3d axisToRotateAround = DVector3d.FromXYZ((60 - 5) * _uorPerMeter, (30 - 10) * _uorPerMeter, (35 - 10) * _uorPerMeter);
    
    	//Point the vector passes through - midpoint of the lineToRotateAround = intersection point between the two segments
    	//As the point is located in lineToRotate only rotation will be performed.
    	DPoint3d pointOnLine = DPoint3d.FromXYZ(32.5 * _uorPerMeter, 20 * _uorPerMeter, 22.5 * _uorPerMeter);
    
    	//Rotate with SDK method
    	DTransform3d transform = DTransform3d.FromRotationAroundLine(pointOnLine, axisToRotateAround, Angle.FromDegrees(90));
    	if (transform == null)
    		return;
    	TransformInfo tInfo = new TransformInfo(transform);
    	if (tInfo == null)
    		return;
    
    	//Apply transform to lineToRotate.
    	lineToRotate.ApplyTransform(tInfo);
    
    	//Get the rotated Segment to check rotation
    	DSegment3d rotatedSegment = new DSegment3d();
    	lineToRotate.AsCurvePathEdit().GetCurveVector().GetPrimitive(0).TryGetLine(out rotatedSegment);
    	}
    

    The result can be seem below (FIG 1)

    Fig 2 shows a line element (cyan) rotated by different angles around the same line (or axis) but using different points along the line. To achieve this you need to translate the element to rotate to the point where the rotation should occur, and then apply the rotation. If not translated the method will apply both rotation and translation at same time and the result will be different.