本文整理汇总了C#中Vector.IsZeroVector方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.IsZeroVector方法的具体用法?C# Vector.IsZeroVector怎么用?C# Vector.IsZeroVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.IsZeroVector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: By2PointsCore
private static ICircleEntity By2PointsCore(Point firstPoint, Point secondPoint, ref Vector normal)
{
if (null == firstPoint)
throw new ArgumentNullException("firstPoint");
if (null == secondPoint)
throw new ArgumentNullException("secondPoint");
if (null == normal)
throw new ArgumentNullException("normal");
if (firstPoint.Equals(secondPoint))
throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "first point", "second point"), "firstPoint, secondPoint");
if (normal.IsZeroVector())
throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal"), "normal");
var fptPos = firstPoint.PointEntity;
var sptPos = secondPoint.PointEntity;
var cptPos = HostFactory.Factory.CreatePoint((fptPos.X + sptPos.X) / 2.0,
(fptPos.Y + sptPos.Y) / 2.0,
(fptPos.Z + sptPos.Z) / 2.0);
var centerPt = cptPos.ToPoint(false, null);
var circleEntity = Circle.ByCenterPointRadiusCore(centerPt, cptPos.DistanceTo(fptPos), ref normal);
if (circleEntity == null)
throw new Exception(string.Format(Properties.Resources.OperationFailed, "Circle.By2Points"));
return circleEntity;
}
示例2: ByCenterPointRadiusCore
private static ICircleEntity ByCenterPointRadiusCore(Point centerPoint, double radius, ref Vector normal)
{
if (null == centerPoint)
throw new ArgumentNullException("centerPoint");
if (null == normal)
throw new ArgumentNullException("normal");
if (normal.IsZeroVector())
throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal"), "normal");
if (radius <= 0.0)
throw new ArgumentException(Properties.Resources.IsZeroRadius);
normal = normal.IsNormalized ? normal : normal.Normalize();
ICircleEntity entity = HostFactory.Factory.CircleByCenterPointRadius(centerPoint.PointEntity, radius, normal.IVector);
if (null == entity)
throw new Exception(string.Format(Properties.Resources.OperationFailed, "Circle.ByCenterPointRadius"));
return entity;
}
示例3: Project
/// <summary>
/// Constructs a point by projecting a point on surface with given
/// project direction.
/// </summary>
/// <param name="contextSurface">The surface on which the projection is to be made.</param>
/// <param name="direction">The direction vector of the projection</param>
/// <returns>Projected point on surface</returns>
public Point Project(Surface contextSurface, Vector direction)
{
if (null == contextSurface)
throw new ArgumentNullException("contextSurface");
if (null == direction || direction.IsZeroVector())
throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, direction, "Project on surface"), "direction");
Point pt = ProjectOnGeometry(contextSurface, direction);
pt.Context = contextSurface;
pt.Direction = direction;
pt.ReferencePoint = this;
double[] parameters = contextSurface.ParameterAtPoint(pt);
if (null != parameters)
{
pt.U = parameters[0];
pt.V = parameters[1];
}
return pt;
}
示例4: AtParameter
/// <summary>
/// Constructor that does the same as CoordinateSystem.AtParameter but that it checks if the z-axis is
/// in the same general direction as the given upVector. If not, it flips the z-axis to make it point
/// in the same overall direction as the upVector and also flips the y-axis accordingly to preserve
/// the right-handed CoordinateSystem rule.
/// </summary>
/// <param name="contextCurve"></param>
/// <param name="t"></param>
/// <param name="upVector"></param>
/// <returns></returns>
public static CoordinateSystem AtParameter(Curve contextCurve, double t, Vector upVector)
{
if (contextCurve == null)
throw new System.ArgumentNullException("contextCurve");
else if (upVector == null)
throw new System.ArgumentNullException("upVector");
else if (upVector.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "up vector"), "upVector");
var cs = contextCurve.CoordinateSystemAtParameterCore(t, upVector);
if (null == cs)
throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "CoordinateSystem.AtParameter"));
// property assigments
//
cs.ContextCurve = contextCurve;
cs.T = t;
cs.Distance = contextCurve.DistanceAtParameter(t);
cs.UpVector = upVector;
return cs;
}
示例5: ByCenterPointStartPointSweepAngleCore
private static IArcEntity ByCenterPointStartPointSweepAngleCore(Point centerPoint, Point startPoint, double sweepAngle, ref Vector normal)
{
if (centerPoint == null)
{
throw new ArgumentNullException("centerPoint");
}
else if (startPoint == null)
{
throw new ArgumentNullException("startPoint");
}
else if (normal == null)
{
throw new ArgumentNullException("normal");
}
else if (normal.IsZeroVector())
{
throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal vector"), "normal");
}
else if (centerPoint.Equals(startPoint))
{
throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "center point", "start point"), "centerPoint, startPoint");
}
else if (sweepAngle == 0.0)
{
throw new ArgumentException(string.Format(Properties.Resources.IsZeroAngle, "sweep"), "sweepAngle");
}
normal = normal.IsNormalized ? normal : normal.Normalize();
var entity = HostFactory.Factory.ArcByCenterPointStartPointSweepAngle(centerPoint.PointEntity,
startPoint.PointEntity, GeometryExtension.DegreesToRadians(sweepAngle), normal.IVector);
if (null == entity)
throw new Exception(string.Format(Properties.Resources.OperationFailed, "Arc.ByCenterPointStartPointSweepAngle"));
return entity;
}
示例6: RevolveAsSurface
/// <summary>
/// def RevolveAsSurface(axisOrigin : Point, axisDirection : Vector)
///
/// Returns a Surface by revolving this curve about an axis defined by
/// axisOrigin point and axisDirection Vector. Assuming sweep angle = 360
/// and start angle = 0.
/// </summary>
/// <param name="axisOrigin">Origin Point of axis of revolution</param>
/// <param name="axisDirection">Direction Vector of axis of revolution</param>
/// <returns>Revolved Surface</returns>
public Surface RevolveAsSurface(Point axisOrigin, Vector axisDirection)
{
if (axisOrigin == null)
throw new System.ArgumentNullException("axisOrigin");
else if (axisDirection == null)
throw new System.ArgumentNullException("axisDirection");
else if (axisDirection.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, axisDirection), "axisDirection");
return Surface.Revolve(this, axisOrigin, axisDirection);
}
示例7: Rotate
/// <summary>
/// Rotates the input CoordinateSystem about its own axes and about the global origin (0,0,0) by the given rotation angles
/// in the given rotation sequence. The rotation angles are always specified in the order of rotation about (xAxis, yAxis, zAxis).
/// </summary>
/// <param name="rotationAngle">The angle to be rotated through</param>
/// <param name="axis">The axis to be rotated about</param>
/// <param name="origin">The global origin</param>
/// <returns>Returns a rotated CoordinateSystem</returns>
public CoordinateSystem Rotate(double rotationAngle, Vector axis, Point origin)
{
if (axis == null)
throw new System.ArgumentNullException("axis");
else if (origin == null)
throw new System.ArgumentNullException("origin");
else if (axis.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "axis"), "axis");
var rotatedCSEntity = CSEntity.Rotation(rotationAngle, axis.IVector, origin.PointEntity);
var cs = new CoordinateSystem(rotatedCSEntity, true);
return cs;
}
示例8: RevolveAsSolid
/// <summary>
/// def RevolveAsSolid : Solid (axisOrigin : Point, axisDirection : Vector)
///
/// Returns a Solid by revolving close curve about an axis defined by
/// axisOrigin point and axisDirection Vector. Assuming sweep angle = 360
/// and start angle = 0.
/// </summary>
/// <param name="axisOrigin">Origin point of axis of revolution</param>
/// <param name="axisDirection">Direction vector of axis of revolution</param>
/// <returns>Revolved Solid</returns>
public Solid RevolveAsSolid(Point axisOrigin, Vector axisDirection)
{
if (axisOrigin == null)
throw new System.ArgumentNullException("axisOrigin");
else if (axisDirection == null)
throw new System.ArgumentNullException("axisDirection");
else if (!IsClosed)
throw new System.InvalidOperationException(Properties.Resources.CurveNotClosed);
else if (!IsPlanar)
throw new System.InvalidOperationException(Properties.Resources.CurveNotPlanar);
else if (axisDirection.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, axisDirection), "axisDirection");
return Solid.Revolve(this, axisOrigin, axisDirection);
}
示例9: Project
/// <summary>
/// Projects the given point along the given direction onto this curve
/// </summary>
/// <param name="point">Point for projection</param>
/// <param name="direction">Direction for projection</param>
/// <returns>Project point on curve</returns>
internal Point Project(Point point, Vector direction)
{
string kMethodName = "Curve.Project";
if (point == null)
throw new System.ArgumentNullException("point");
else if (direction == null)
throw new System.ArgumentNullException("direction");
else if (direction.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, direction), "direction");
IPointEntity projectedPt = CurveEntity.Project(point.PointEntity, direction.IVector);
if (projectedPt == null)
throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName));
return projectedPt.ToPoint(true, this);
}
示例10: ByPoints
/// <summary>
///
/// </summary>
/// <param name="pts"></param>
/// <param name="startTangent"></param>
/// <param name="endTangent"></param>
/// <returns></returns>
public static BSplineCurve ByPoints(Point[] pts, Vector startTangent, Vector endTangent)
{
if (pts == null || startTangent == null || endTangent == null ||
startTangent.IsZeroVector() || endTangent.IsZeroVector())
{
return null;
}
IBSplineCurveHost ent = HostFactory.Factory.BSplineByPoints(pts.ToHostArray(), startTangent, endTangent);
var spline = new BSplineCurve(ent, true);
spline.Points = pts;
spline.Degree = 3;
spline.StartTangent = startTangent;
spline.EndTangent = endTangent;
return spline;
}
示例11: Project
/// <summary>
///
/// </summary>
/// <param name="point"></param>
/// <param name="direction"></param>
/// <returns></returns>
public Point Project(Point point, Vector direction)
{
if (point == null || direction == null || direction.IsZeroVector())
{
return null;
}
IPointEntity projectedPt = PlaneEntity.Project(point.PointEntity, direction.IVector);
if (null == projectedPt)
{
return null;
}
return projectedPt.ToPoint(true, this);
}
示例12: ByStartPointDirectionLengthCore
private static ILineEntity ByStartPointDirectionLengthCore(Point startPt, Vector direction, double length)
{
if (startPt == null)
{
throw new ArgumentNullException("startPt");
}
else if (direction == null)
{
throw new ArgumentNullException("direction");
}
else if (direction.IsZeroVector() || length == 0.0)
{
throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "direction"));
}
else if (length == 0.0)
{
throw new ArgumentException(Properties.Resources.IsZeroLength);
}
//Temporary end point is created by translating, should be disposed
Vector offset = direction.Normalize().MultiplyBy(length);
var endPt = startPt.Translate(offset, false);
ILineEntity entity = HostFactory.Factory.LineByStartPointEndPoint(startPt.PointEntity, endPt.PointEntity);
if (null == entity)
throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "Line.ByStartPointDirectionLength"));
return entity;
}
示例13: ByOriginNormalCore
private static IPlaneEntity ByOriginNormalCore(Point origin, ref Vector normal, double size)
{
if (origin == null)
{
throw new ArgumentNullException("origin");
}
else if (normal == null)
{
throw new ArgumentNullException("normal");
}
else if (normal.IsZeroVector())
throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, normal), "normal");
normal = normal.IsNormalized ? normal : normal.Normalize();
IPlaneEntity entity = HostFactory.Factory.PlaneByOriginNormal(origin.PointEntity, normal.IVector);
if (null == entity)
throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "Plane.ByOriginNormal"));
return entity;
}
示例14: ByOriginVectors
internal static CoordinateSystem ByOriginVectors(Point origin, Vector xAxis, Vector yAxis, Vector zAxis,
bool isSheared, bool isNormalized, bool visible)
{
if (origin == null)
throw new System.ArgumentNullException("origin");
else if (xAxis == null)
throw new System.ArgumentNullException("xAxis");
else if (yAxis == null)
throw new System.ArgumentNullException("yAxis");
else if (zAxis == null)
throw new System.ArgumentNullException("zAxis");
else if (xAxis.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "x axis"), "xAxis");
else if (yAxis.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "y axis"), "yAxis");
else if (zAxis.IsZeroVector())
throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "z axis"), "zAxis");
else if (xAxis.IsParallel(yAxis))
throw new System.ArgumentException(string.Format(Properties.Resources.IsParallel, "x axis", "y axis", "CoordinateSystem.ByOriginVectors"), "xAxis, yAxis");
else if (!isSheared && (!xAxis.IsPerpendicular(yAxis) || !yAxis.IsPerpendicular(zAxis) || !zAxis.IsPerpendicular(xAxis)))
{
// this is not the case for sheared but axes are not orthogonal
//
zAxis = xAxis.Cross(yAxis);
yAxis = zAxis.Cross(xAxis);
}
if (isNormalized)
{
xAxis = xAxis.Normalize();
yAxis = yAxis.Normalize();
zAxis = zAxis.Normalize();
}
var cs = HostFactory.Factory.CoordinateSystemByData(null); //create identity matrix
if (null == cs)
throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "CoordinateSystem.ByOriginVectors"));
cs.Set(origin.PointEntity, xAxis.IVector, yAxis.IVector, zAxis.IVector);
var coordSys = new CoordinateSystem(cs, visible);
return coordSys;
}
示例15: ByCenterPointRadiusAngleCore
private static IArcEntity ByCenterPointRadiusAngleCore(Point centerPoint, double radius, double startAngle, double sweepAngle, ref Vector normal)
{
if (centerPoint == null)
{
throw new ArgumentNullException("centerPoint");
}
else if (normal == null)
{
throw new ArgumentNullException("normal");
}
else if (radius <= 0.0)
{
throw new ArgumentException(string.Format(Properties.Resources.LessThanZero, "radius"));
}
else if (normal.IsZeroVector())
{
throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, normal), "normal");
}
normal = normal.IsNormalized ? normal : normal.Normalize();
var endAngle = (startAngle + sweepAngle);
IArcEntity entity = HostFactory.Factory.ArcByCenterPointRadiusAngle(centerPoint.PointEntity, radius, GeometryExtension.DegreesToRadians(startAngle), GeometryExtension.DegreesToRadians(endAngle), normal.IVector);
if (null == entity)
throw new Exception(string.Format(Properties.Resources.OperationFailed, "Arc.ByCenterPointRadiusAngle"));
return entity;
}