Scale operation is seem incorrect

Hi,
My system is Rhino 6 SR13 C++ SDK 6.13.19058.00371
The member function of class ON_Xform,
void Scale(const ON_Plane& plane, double x_scale_factor, double y_scale_factor, double z_scale_factor);
the result of the scale operation is seem incorrect, but it is corrent in Rhino 5 C++ SDK.
I exchange the parameters y_scale_factor and z_scale_factor to get the correct result.
Is it a bug?

Hi @john12,

This works as expected:

CRhinoCommand::result CCommandTest6::RunCommand(const CRhinoCommandContext& context)
{
  // Define points for unit box
  ON_3dPointArray points;
  points.Append(ON_3dPoint(0.0, 0.0, 0.0));
  points.Append(ON_3dPoint(1.0, 0.0, 0.0));
  points.Append(ON_3dPoint(1.0, 1.0, 0.0));
  points.Append(ON_3dPoint(0.0, 1.0, 0.0));
  points.Append(ON_3dPoint(0.0, 0.0, 1.0));
  points.Append(ON_3dPoint(1.0, 0.0, 1.0));
  points.Append(ON_3dPoint(1.0, 1.0, 1.0));
  points.Append(ON_3dPoint(0.0, 1.0, 1.0));

  // Create unit box and add to document
  ON_Brep brep;
  if (nullptr == ON_BrepBox(points.Array(), &brep))
    return CRhinoCommand::failure;

  context.m_doc.AddBrepObject(brep);

  // Create scale transformation
  ON_Xform xform = ON_Xform::ScaleTransformation(ON_Plane::World_xy, 6.0, 4.0, 2.0);

  // Scale unit box and add to document
  brep.Transform(xform);
  context.m_doc.AddBrepObject(brep);

  context.m_doc.Redraw();

  return CRhinoCommand::success;
}

Feel free to post any code you cannot make work correctly.

– Dale

ON_3dPointArray points;
points.Append(ON_3dPoint(0.0, 0.0, 0.0));
points.Append(ON_3dPoint(1.0, 0.0, 0.0));
points.Append(ON_3dPoint(1.0, 1.0, 0.0));
points.Append(ON_3dPoint(0.0, 1.0, 0.0));
points.Append(ON_3dPoint(0.0, 0.0, 1.0));
points.Append(ON_3dPoint(1.0, 0.0, 1.0));
points.Append(ON_3dPoint(1.0, 1.0, 1.0));
points.Append(ON_3dPoint(0.0, 1.0, 1.0));
ON_Brep brep;
if (ON_BrepBox(points.Array(), &brep) == NULL)
return CRhinoCommand::success;
ON_Xform xform = ON_Xform::ScaleTransformation(ON_Plane::World_xy, 6.0, 4.0, 2.0);
ON_Xform trsf = ON_Xform::IdentityTransformation; trsf.Scale(ON_xy_plane, 6.0, 4.0, 2.0);
ON_Brep brep1 = ON_Brep(brep);
ON_Brep brep2 = ON_Brep(brep);
brep1.Transform(xform);
brep2.Transform(trsf);
context.m_doc.AddBrepObject(brep);
context.m_doc.AddBrepObject(brep1);
context.m_doc.AddBrepObject(brep2);
context.m_doc.Redraw();

//brep2 is incorrect

@john12, the version of ON_Xform::Scale you’re calling has been deprecated (obsolete). Use the static version that I demonstrated earlier.

– Dale