By Adam Nagy
If you are trying to create a transformation matrix and e.g. because of imprecision it will get a scaling factor, and this scaling factor is non-uniform (i.e. different value along the X, Y or Z axis) then you cannot use it to transform certain entities like a Polyline. If you try it you'll get an eCannotScaleNonUniformly error. If you do not want to scale at all, you can just remove the scaling factor like so:
Public Sub RemoveScaling(ByRef mx As Matrix3d)
Dim axes As New List(Of Vector3d)
For i As Integer = 0 To 2
Dim vec As New Vector3d(mx(i, 0), mx(i, 1), mx(i,2))
' This will make the vector have length = 1.0
vec = vec.GetNormal()
axes.Add(vec)
Next
mx = New Matrix3d(New Double() _
{
axes(0).X, axes(0).Y, axes(0).Z, mx(0, 3),
axes(1).X, axes(1).Y, axes(1).Z, mx(1, 3),
axes(2).X, axes(2).Y, axes(2).Z, mx(2, 3),
mx(3, 0), mx(3, 1), mx(3, 2), mx(3,3)
})
End Sub
The same way you could also make sure that the scaling is uniform by making the length of each axis vector the same. You would need to modify the above code like so:
vec = vec.GetNormal().MultiplyBy(scalingValue)

Leave a Reply to SrinivasanCancel reply