# GH_GeometricGoo inherit Transform and Morph

I am learning how to create custom data types and custom params in GH. I cannot find any example of how to implement Transform and Morph in GeometricGoo. Can someone post some reference ?

The methods must apply the transformation or spacemorph to the instance it’s called on, and return the modified shape. Since certain data types cannot be transformed without becoming other data types, the functions both return a non-specific result.

For example circles can be transformed sometimes and still be circles, but if the transformation includes shearing, or a non-uniform dilation, or a tapering, then circles become ellipses. Circles will almost never remain circles during spacemorphs, so I don’t even try to retain them in that case:

``````public override IGH_GeometricGoo Transform(Transform xform)
{
if (!IsValid) return null;
if (xform.SimilarityType == TransformSimilarityType.NotSimilarity)
{
var nurbs = m_value.ToNurbsCurve();
nurbs.Transform(xform);
return new GH_Curve(nurbs);
}

var circle = m_value;
circle.Transform(xform);
return new GH_Circle(circle);
}

public override IGH_GeometricGoo Morph(SpaceMorph xmorph)
{
if (!IsValid) return null;
var nurbs = m_value.ToNurbsCurve();
xmorph.Morph(nurbs);
return new GH_Curve(nurbs);
}
``````

this line checks if the type of data changes after the transformation xform?

Yes, it checks whether circles will remain circles. Transformations containing only rotations, uniform dilations and translations retain similarity.

but it works only with circles or for example with rectangles too?

“it” ?

The test I perform here would be specific to any geometric type which cannot handle shearing, such as circles, arcs and indeed rectangles. Lines, polylines and nurbs curves on the other hand can always be transformed using a 4x4 matrix without the need to be converted into another type.

So it really depends what sort of shape your data represents. Is it something which can be transformed linearly without bounds? Is it something which can be deformed non-linearly? Or does it have strict constraints? Is there another type of shape you can convert it into?

this i meant by “it”. this check works only on circles to curves or any other type change?