当前位置: 首页>>代码示例>>C#>>正文


C# Matrix3x3.Validate方法代码示例

本文整理汇总了C#中BEPUutilities.Matrix3x3.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix3x3.Validate方法的具体用法?C# Matrix3x3.Validate怎么用?C# Matrix3x3.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BEPUutilities.Matrix3x3的用法示例。


在下文中一共展示了Matrix3x3.Validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputeVolumeDistribution

        /// <summary>
        /// Computes the volume distribution and center of the shape.
        /// </summary>
        /// <param name="entries">Mass-weighted entries of the compound.</param>
        /// <param name="volume">Summed volume of the constituent shapes. Intersecting volumes get double counted.</param>
        /// <param name="volumeDistribution">Volume distribution of the shape.</param>
        /// <param name="center">Center of the compound.</param>
        public static void ComputeVolumeDistribution(IList<CompoundShapeEntry> entries, out float volume, out Matrix3x3 volumeDistribution, out Vector3 center)
        {
            center = new Vector3();
            float totalWeight = 0;
            volume = 0;
            for (int i = 0; i < entries.Count; i++)
            {
                center += entries[i].LocalTransform.Position * entries[i].Weight;
                volume += entries[i].Shape.Volume;
                totalWeight += entries[i].Weight;
            }
            if (totalWeight <= 0)
                throw new NotFiniteNumberException("Cannot compute distribution; the total weight of a compound shape must be positive.");
            float totalWeightInverse = 1 / totalWeight;
            totalWeightInverse.Validate();
            center *= totalWeightInverse;

            volumeDistribution = new Matrix3x3();
            for (int i = 0; i < entries.Count; i++)
            {
                RigidTransform transform = entries[i].LocalTransform;
                Matrix3x3 contribution;
                TransformContribution(ref transform, ref center, ref entries[i].Shape.volumeDistribution, entries[i].Weight, out contribution);
                Matrix3x3.Add(ref volumeDistribution, ref contribution, out volumeDistribution);
            }
            Matrix3x3.Multiply(ref volumeDistribution, totalWeightInverse, out volumeDistribution);
            volumeDistribution.Validate();
        }
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:35,代码来源:CompoundShape.cs

示例2: ComputeVolumeDistribution

        /// <summary>
        /// Computes the volume distribution of the shape.
        /// </summary>
        /// <returns>Volume distribution of the shape.</returns>
        public override Matrix3x3 ComputeVolumeDistribution()
        {
            var volumeDistribution = new Matrix3x3();
            float totalWeight = 0;
            for (int i = 0; i < shapes.Count; i++)
            {
                totalWeight += shapes.Elements[i].Weight;
                Matrix3x3 contribution;
                GetContribution(shapes.Elements[i].Shape, ref shapes.Elements[i].LocalTransform, ref Toolbox.ZeroVector, shapes.Elements[i].Weight, out contribution);
                Matrix3x3.Add(ref contribution, ref volumeDistribution, out volumeDistribution);

            } 
            if (totalWeight <= 0)
                throw new NotFiniteNumberException("Cannot compute distribution; the total weight of a compound shape must be positive.");
            Matrix3x3.Multiply(ref volumeDistribution, 1 / totalWeight, out volumeDistribution);
            volumeDistribution.Validate();
            return volumeDistribution;
        }
开发者ID:dsmo7206,项目名称:Lemma,代码行数:22,代码来源:CompoundShape.cs


注:本文中的BEPUutilities.Matrix3x3.Validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。