本文整理汇总了C#中ConstraintType类的典型用法代码示例。如果您正苦于以下问题:C# ConstraintType类的具体用法?C# ConstraintType怎么用?C# ConstraintType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstraintType类属于命名空间,在下文中一共展示了ConstraintType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRagdollConstraint
void CreateRagdollConstraint(string boneName, string parentName, ConstraintType type,
Vector3 axis, Vector3 parentAxis, Vector2 highLimit, Vector2 lowLimit, bool disableCollision = true)
{
Node boneNode = Node.GetChild(boneName, true);
Node parentNode = Node.GetChild(parentName, true);
if (boneNode == null)
{
Log.Warn($"Could not find bone {boneName} for creating ragdoll constraint");
return;
}
if (parentNode == null)
{
Log.Warn($"Could not find bone {parentName} for creating ragdoll constraint");
return;
}
Constraint constraint = boneNode.CreateComponent<Constraint>();
constraint.ConstraintType = type;
// Most of the constraints in the ragdoll will work better when the connected bodies don't collide against each other
constraint.DisableCollision = disableCollision;
// The connected body must be specified before setting the world position
constraint.OtherBody = parentNode.GetComponent<RigidBody>();
// Position the constraint at the child bone we are connecting
constraint.SetWorldPosition(boneNode.WorldPosition);
// Configure axes and limits
constraint.SetAxis(axis);
constraint.SetOtherAxis(parentAxis);
constraint.HighLimit = highLimit;
constraint.LowLimit = lowLimit;
}
示例2: Load
public IList<DatabaseConstraint> Load(string tableName, string schemaName, ConstraintType constraintType)
{
if (string.IsNullOrEmpty(tableName)) throw new ArgumentNullException("tableName", "must have tableName");
switch (constraintType)
{
case ConstraintType.PrimaryKey:
return PrimaryKeys(tableName, schemaName);
case ConstraintType.ForeignKey:
return ForeignKeys(tableName, schemaName);
case ConstraintType.UniqueKey:
return _ukConverter.Constraints(tableName, schemaName);
case ConstraintType.Check:
return _ckConverter.Constraints(tableName, schemaName);
case ConstraintType.Default:
return _dfConverter.Constraints(tableName, schemaName);
default:
throw new ArgumentOutOfRangeException("constraintType");
}
}
示例3: Constraint
/// <summary>
/// Initializes a new instance of the <see cref="Constraint"/> class.
/// </summary>
/// <param name="condition">The condition.</param>
/// <param name="constraintColumnName">Name of the constraint column.</param>
public Constraint(ConstraintType condition, string constraintColumnName)
{
Condition = condition;
ColumnName = constraintColumnName;
QualifiedColumnName = constraintColumnName;
ConstructionFragment = constraintColumnName;
}
示例4: NonlinearConstraint
/// <summary>
/// Constructs a new nonlinear constraint.
/// </summary>
///
/// <param name="objective">The objective function to which this constraint refers.</param>
/// <param name="function">A lambda expression defining the left hand side of the
/// constraint equation.</param>
/// <param name="shouldBe">How the left hand side of the constraint should be
/// compared to the given <paramref name="value"/>.</param>
/// <param name="value">The right hand side of the constraint equation.</param>
///
public NonlinearConstraint(IObjectiveFunction objective,
Func<double[], double> function, ConstraintType shouldBe, double value)
{
int n = objective.NumberOfVariables;
this.Create(objective.NumberOfVariables, function, shouldBe, value, null, 0.0);
}
示例5: ColumnConstraintInfo
public ColumnConstraintInfo(ConstraintType constraintType)
{
if (constraintType == ConstraintType.Check)
throw new ArgumentException("Check is not a column-level constraint");
ConstraintType = constraintType;
}
示例6: Constraint
/// <summary>
/// Constructor using only the Main Table.
/// </summary>
/// <param name="type"></param>
/// <param name="table"></param>
/// <param name="col"></param>
public Constraint(ConstraintType type, Table table, int[] col)
{
_type = type;
_mainTable = table;
_mainColumns = col;
_len = col.Length;
}
示例7: QuadraticConstraint
/// <summary>
/// Constructs a new quadratic constraint in the form <c>x'Ax + x'b</c>.
/// </summary>
///
/// <param name="objective">The objective function to which this constraint refers.</param>
/// <param name="quadraticTerms">The matrix of <c>A</c> quadratic terms.</param>
/// <param name="linearTerms">The vector <c>b</c> of linear terms.</param>
/// <param name="shouldBe">How the left hand side of the constraint should be compared to the given <paramref name="value"/>.</param>
/// <param name="value">The right hand side of the constraint equation.</param>
/// <param name="withinTolerance">The tolerance for violations of the constraint. Equality
/// constraints should set this to a small positive value. Default is 0.</param>
///
public QuadraticConstraint(IObjectiveFunction objective,
double[,] quadraticTerms, double[] linearTerms = null,
ConstraintType shouldBe = ConstraintType.LesserThanOrEqualTo,
double value = 0, double withinTolerance = 0.0)
{
int n = objective.NumberOfVariables;
if (quadraticTerms == null)
throw new ArgumentNullException("quadraticTerms");
if (quadraticTerms.GetLength(0) != quadraticTerms.GetLength(1))
throw new DimensionMismatchException("quadraticTerms", "Matrix must be square.");
if (quadraticTerms.GetLength(0) != n)
throw new DimensionMismatchException("quadraticTerms",
"Matrix rows must match the number of variables in the objective function.");
if (linearTerms != null)
{
if (linearTerms.Length != n)
throw new DimensionMismatchException("linearTerms",
"The length of the linear terms vector must match the "+
"number of variables in the objective function.");
}
else
{
linearTerms = new double[n];
}
this.QuadraticTerms = quadraticTerms;
this.LinearTerms = linearTerms;
Create(objective, function, shouldBe, value, gradient, withinTolerance);
}
示例8: Constraint
protected Constraint(ObjectName name, Table table, ConstraintType constraintType, IEnumerable<Column> keyColumns)
{
_name = name;
_table = table;
_constraintType = constraintType;
_keyColumns = new List<Column>(keyColumns);
}
示例9: ResetLink
// Set all the parameters for this constraint to a fixed, non-movable constraint.
public override void ResetLink()
{
// constraintType = ConstraintType.D6_CONSTRAINT_TYPE;
constraintType = ConstraintType.BS_FIXED_CONSTRAINT_TYPE;
linearLimitLow = OMV.Vector3.Zero;
linearLimitHigh = OMV.Vector3.Zero;
angularLimitLow = OMV.Vector3.Zero;
angularLimitHigh = OMV.Vector3.Zero;
useFrameOffset = BSParam.LinkConstraintUseFrameOffset;
enableTransMotor = BSParam.LinkConstraintEnableTransMotor;
transMotorMaxVel = BSParam.LinkConstraintTransMotorMaxVel;
transMotorMaxForce = BSParam.LinkConstraintTransMotorMaxForce;
cfm = BSParam.LinkConstraintCFM;
erp = BSParam.LinkConstraintERP;
solverIterations = BSParam.LinkConstraintSolverIterations;
frameInAloc = OMV.Vector3.Zero;
frameInArot = OMV.Quaternion.Identity;
frameInBloc = OMV.Vector3.Zero;
frameInBrot = OMV.Quaternion.Identity;
useLinearReferenceFrameA = true;
springAxisEnable = new bool[6];
springDamping = new float[6];
springStiffness = new float[6];
for (int ii = 0; ii < springAxisEnable.Length; ii++)
{
springAxisEnable[ii] = false;
springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED;
springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED;
}
springLinearEquilibriumPoint = OMV.Vector3.Zero;
springAngularEquilibriumPoint = OMV.Vector3.Zero;
member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID);
}
示例10: Set
public IVariable Set(IMilpManager milpManager, ConstraintType type, IVariable leftVariable,
IVariable rightVariable)
{
switch (type)
{
case ConstraintType.Equal:
milpManager.SetEqual(leftVariable, rightVariable);
leftVariable.ConstantValue = rightVariable.ConstantValue ?? leftVariable.ConstantValue;
rightVariable.ConstantValue = leftVariable.ConstantValue ?? rightVariable.ConstantValue;
break;
case ConstraintType.LessOrEqual:
milpManager.SetLessOrEqual(leftVariable, rightVariable);
break;
case ConstraintType.GreaterOrEqual:
milpManager.SetGreaterOrEqual(leftVariable, rightVariable);
break;
case ConstraintType.LessThan:
milpManager.Operation(OperationType.IsLessThan, leftVariable, rightVariable)
.Set(ConstraintType.Equal, milpManager.FromConstant(1));
break;
case ConstraintType.GreaterThan:
milpManager.Operation(OperationType.IsGreaterThan, leftVariable, rightVariable)
.Set(ConstraintType.Equal, milpManager.FromConstant(1));
break;
case ConstraintType.NotEqual:
milpManager.Operation(OperationType.IsNotEqual, leftVariable, rightVariable)
.Set(ConstraintType.Equal, milpManager.FromConstant(1));
break;
default:
throw new InvalidOperationException("Cannot set constraint");
}
return leftVariable;
}
示例11: ConstraintAttribute
public ConstraintAttribute(ConstraintType type)
{
if (type == ConstraintType.ForeignKey)
throw new NotImplementedException();
Type = type;
}
示例12: ConstraintMapInfo
internal ConstraintMapInfo(MemberInfo member, string columnName, ConstraintType constraintType, string checkExpression)
{
Member = member;
ColumnName = columnName;
ConstraintType = constraintType;
CheckExpression = checkExpression;
}
示例13: Set
public IVariable Set(IMilpManager milpManager, ConstraintType type, IVariable leftVariable, IVariable rightVariable)
{
IVariable any = milpManager.CreateAnonymous(Domain.AnyInteger);
leftVariable.Set(ConstraintType.Equal,any.Operation(OperationType.Multiplication, rightVariable));
return leftVariable;
}
示例14: CheckFirebird
private void CheckFirebird(DataTable dt, ConstraintType constraintType)
{
if (constraintType == ConstraintType.PrimaryKey && !dt.Columns.Contains(Key)) Key = "PK_NAME";
if (constraintType == ConstraintType.ForeignKey && !dt.Columns.Contains(Key)) Key = "UK_NAME";
if (!dt.Columns.Contains(RefersToTableKey)) RefersToTableKey = "REFERENCED_TABLE_NAME";
//a firebird typo!
if (dt.Columns.Contains("CHECK_CLAUSULE")) ExpressionKey = "CHECK_CLAUSULE";
}
示例15: SqlqueryCondition
/// <summary>
/// SqlQuery条件类构造函数
/// </summary>
/// <param name="ctype">查询类型,包括:Where、And、Or</param>
/// <param name="columnname">条件列名</param>
/// <param name="cparsion">条件表达式类型</param>
/// <param name="value">条件值</param>
/// <param name="isParentheses">是否加左括号</param>
public SqlqueryCondition(ConstraintType ctype, string columnname, Comparison cparsion, object value, bool isParentheses = false)
{
SQConstraintType = ctype;
SQColumnName = columnname;
SQComparison = cparsion;
SQValue = value;
IsParentheses = isParentheses;
}