本文整理汇总了C#中Vehicle.GetMassCenter方法的典型用法代码示例。如果您正苦于以下问题:C# Vehicle.GetMassCenter方法的具体用法?C# Vehicle.GetMassCenter怎么用?C# Vehicle.GetMassCenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle.GetMassCenter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawMassCenter
private void DrawMassCenter(Vehicle vehicle, Canvas canvas, Direction dir)
{
var point3D = vehicle.GetMassCenter();
var circleDiameter = 20;
double height;
if (dir == Direction.Up)
{
height = canvas.Height - point3D.Z/Scale - circleDiameter/2;
}
else
{
height = point3D.Y/Scale - circleDiameter/2;
}
var ellipse = new Ellipse();
ellipse.Width = circleDiameter;
ellipse.Height = circleDiameter;
Brush brush = new SolidColorBrush();
brush = Brushes.Black;
ellipse.Stroke = new SolidColorBrush(Colors.Black);
ellipse.StrokeThickness = 2;
ellipse.Fill = brush;
Canvas.SetLeft(ellipse, point3D.X/Scale - circleDiameter/2);
Canvas.SetTop(ellipse, height);
canvas.Children.Add(ellipse);
}
示例2: CheckOverweight
private void CheckOverweight(Vehicle vehicle, TextBox textBox, int MaxTonnage)
{
var p = vehicle.GetMassCenter();
var maxTonnage = MaxTonnage*(vehicle.EmptyTonnage*vehicle.Length + 2*p.X*vehicle.Mass)/(vehicle.Length*(vehicle.EmptyTonnage + vehicle.Mass));
if (vehicle.Mass > maxTonnage & p.X < vehicle.Length/2)
{
textBox.AppendText("Превышение нагрузки на переднюю ось \n");
}
if (vehicle.Mass > maxTonnage & p.X > vehicle.Length/2)
{
textBox.AppendText("Превышение нагрузки на заднюю ось \n");
}
if (vehicle.Mass > maxTonnage & p.X == vehicle.Length/2)
{
textBox.AppendText("Превышение нагрузки на все оси \n");
}
}