Closed saklanmazozgur closed 10 months ago
You need to calculate the center point yourself by calculating the center point of the geometry vertices loaded from your model.
In my question is a clue of how to find the center point. The uploaded file type is .stl. How can I find the center point of this file with helixtoolkit?
I did it in my own project by finding the bounding sphere. If you have a geometry made of several parts you'll need to find the bounding sphere of two spheres. Here is my code that does it:
private static SharpDX.BoundingSphere Merge(SharpDX.BoundingSphere s1, SharpDX.BoundingSphere s2)
{
if (s1.Radius == 0f)
{
return s2;
}
if (s2.Radius == 0f)
{
return s1;
}
var s1s2 = s1.Center - s2.Center;
var distance = s1s2.Length();
// Co-centric sphere => return biggest one
if (distance == 0f)
{
return s1.Radius > s2.Radius ? s1 : s2;
}
// One sphere is fully contained into the other one
if (distance <= Math.Abs(s1.Radius - s2.Radius))
{
return s1.Radius > s2.Radius ? s1 : s2;
}
var unit = s1s2.Normalized();
var point1 = s1.Center + s1.Radius * unit;
var point2 = s2.Center - s2.Radius * unit;
var diameter = point2 - point1;
var radius = diameter.Length() / 2f;
var center = point1 + diameter.Normalized() * radius;
return new SharpDX.BoundingSphere(center, radius);
}
You can use Size property of model,
... var x_middle_point =device3D.Content.Bounds.SizeX/2; var y_middle_point= device3D.Content.Bounds.SizeY/2; var z_middle_point= device3D.Content.Bounds.SizeZ/2; Point3D middlePoint=new Point3D(x_middle_point ,y_middle_point, z_middle_point); ...
Hi,
I can view a 3D object as follows. I want to rotate this object according to certain values, but the object is not rotating from its center point. Object rotates through corner points.
I need to use the RotateAt command instead of the rotate command, but I could not find how to determine the object's center point. Thanks for the information.
`
`
xaml Code
`