/// <summary> /// Retrieve the boundaries from the renderer extents of the game object and its children /// </summary> /// <param name="activeGO"> /// The parent <see cref="GameObject"/> to start with /// </param> /// <returns> /// The bounds from the renderer extents and all its children. /// </returns> public static Bounds GetHierarchyBounds(GameObject activeGO, BoundType type) { switch (type) { case BoundType.Collider : return ColliderExtents.GetHierarchyBounds(activeGO); case BoundType.Renderer : return RendererExtents.GetHierarchyBounds(activeGO); default: return new Bounds(Vector3.zero, Vector3.zero); } }
/// <summary> /// Retrieve the maximum coordinates for each axis from a transform list /// </summary> /// <param name="referencePosition"> /// The first position to be used as a reference, in a <see cref="Vector3"/> /// </param> /// <param name="transformList"> /// The <see cref="Transform[]"/> to retrieve position from /// </param> /// <returns> /// The maximum extents in a <see cref="Vector3"/> /// </returns> public static Vector3 GetMaxMarkPosition(Vector3 referencePosition, Transform[] transformList, BoundType type) { switch (type) { case BoundType.Collider : return ColliderExtents.GetMaxMarkPosition(referencePosition, transformList); case BoundType.Renderer : return RendererExtents.GetMaxMarkPosition(referencePosition, transformList); default: return BasicExtents.GetMaxMarkPosition(referencePosition, transformList); } }
public IBoundType CreateType(string name, BoundTypeKind type) { var result = new BoundType(this, name, type); _types.Add(result); return result; }
public static ComparisonTypeViewModel Locate(BoundType type) { var name = string.Empty; switch (type) { case BoundType.EqualTo: name = EqualTo; break; case BoundType.LessThan: name = LessThan; break; case BoundType.LessThanOrEqual: name = LessThanOrEqual; break; case BoundType.GreaterThan: name = GreaterThan; break; case BoundType.GreaterThanOrEqual: name = GreaterThanOrEqual; break; case BoundType.Between: name = Between; break; case BoundType.EitherOr: name = Either; break; case BoundType.NotApplicable: name = NotApplicable; break; default: break; } return(AllTypesAsViewModels .FirstOrDefault(i => i.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase))); }
/// <summary> /// Checks whether specified value is in range. /// </summary> /// <typeparam name="T">Type of value to check.</typeparam> /// <param name="value">Value to check.</param> /// <param name="left">Range left bound.</param> /// <param name="right">Range right bound.</param> /// <param name="boundType">Range endpoints bound type.</param> /// <returns><see langword="true"/>, if <paramref name="value"/> is in its bounds.</returns> public static bool Between <T>(this T value, T left, T right, BoundType boundType = BoundType.Open) where T : IComparable <T> { switch (Math.Sign(value.CompareTo(left)) + Math.Sign(value.CompareTo(right))) { case 0: return(true); case 1: return((boundType & BoundType.RightClosed) != 0); case -1: return((boundType & BoundType.LeftClosed) != 0); default: return(false); } }
private StatType( int statPointIncreaseAmount, BoundType boundType, string name, string spriteLoc, string description, Color color, Color negativeColor) { attributeBounds.TryGetValue(boundType, out Bounds); this.StatPointIncreaseAmount = statPointIncreaseAmount; this.Name = name; this.Sprite = Util.LoadIcon(spriteLoc); this.Description = description; this.Color = color; this.order = orderCounter++; this.NegativeColor = negativeColor; allTypes.Add(this); }
protected virtual void VisitType(BoundType node) { switch (node.Kind) { case BoundNodeKind.StructType: VisitStructType((BoundStructType)node); break; case BoundNodeKind.ClassType: VisitClassType((BoundClassType)node); break; case BoundNodeKind.InterfaceType: VisitInterfaceType((BoundInterfaceType)node); break; default: throw new InvalidOperationException(node.Kind.ToString()); } }
public void TestBoundRangeValuesExplicitCheck() { var bound = new BoundType <int>().Add(new RangeConstraint <int>(5, 10)).OnExplicitCheck().Create(5); Assert.AreEqual(5, bound.Value); for (int i = 6; i < 11; i++) { bound = bound.Set(i); Assert.AreEqual(i, bound.Value); } bound = bound.Set(4); Assert.False(bound.IsValid, "bound.IsValid"); Assert.AreNotEqual(10, bound.Value); bound = bound.Set(11); Assert.False(bound.IsValid, "bound.IsValid"); Assert.AreNotEqual(10, bound.Value); }
private static bool InRange(BoundType boundType, int lowCompare, int highCompare) { switch (boundType) { case BoundType.Include: return(lowCompare >= 0 && highCompare <= 0); case BoundType.Exclude: return(lowCompare > 0 && highCompare < 0); case BoundType.IncludeExclude: return(lowCompare >= 0 && highCompare < 0); case BoundType.ExcludeInclude: return(lowCompare > 0 && highCompare <= 0); default: throw new NotSupportedException($"Bound type '{boundType}' is unsupported."); } }
private object Instantiate(UnityEngine.Object unityObject, GameObjectAttribute gameObjectAttribute) { string gameObjectName; if (gameObjectAttribute.name == null) { gameObjectName = BoundType.Name + (BoundName == null ? "" : "_" + BoundName); int c = 1; while (UnityEngine.GameObject.Find("/" + gameObjectName) != null) { gameObjectName = BoundType.Name + (BoundName == null ? "" : "_" + BoundName) + "(" + (c++) + ")"; } } else { gameObjectName = gameObjectAttribute.name; } //UnityEngine.GameObject instanceParent = new UnityEngine.GameObject(gameObjectName); GameObject instance = GameObject.Instantiate(unityObject as GameObject /*, instanceParent.transform*/) as GameObject; instance.name = gameObjectName; foreach (MonoBehaviour monoBehaviour in instance.GetComponentsInChildren <MonoBehaviour>()) { if (monoBehaviour != null) { wire.Inject(monoBehaviour); } } /* if (type.IsAssignableFrom(typeof(Component))) * { * return instance.GetComponent(type); * } else*/ if (BoundType.IsAssignableFrom(typeof(GameObject))) { return(instance); } return(instance.GetComponent(BoundType)); //throw new Exception("Unexpected binding type " + type); }
private void MyLog(string channelname, BoundType bound, BatchStatus status, string message) { using (System.Data.Entity.DbContextTransaction dbTran = upsertContext.Database.BeginTransaction()) { try { Batch batch = new Batch { name = channelname, bound = bound, status = status, message = message }; upsertContext.Batches.Add(batch); upsertContext.SaveChanges(); dbTran.Commit(); } catch (Exception e) { log.Error(e); dbTran.Rollback(); } dbTran.Dispose(); } }
/// <inheritdoc/> public object Convert(object value, Type targetType, object parameter, string language) { BoundType val = BoundType.EqualTo; if (value is BoundType) { val = (BoundType)value; } InputScope scope = new InputScope(); InputScopeName scopeName = new InputScopeName(InputScopeNameValue.Text); if (val == BoundType.Between || val == BoundType.GreaterThan || val == BoundType.LessThan) { scopeName = new InputScopeName(InputScopeNameValue.NumberFullWidth); } scope.Names.Add(scopeName); return(scope); }
public static string BoundToString(BoundType type) { string bound = ""; switch (type) { case BoundType.Equal: bound = "=="; break; case BoundType.SmallerEqual: bound = "<="; break; case BoundType.NotEqual: bound = "!="; break; } return(bound); }
private bool HitVerticalBounds(BoundType boundType) { var hit = false; switch (boundType) { case BoundType.Top: { hit = true; SignalsManager.Broadcast(_hitTopBoundSignal.Name); break; } case BoundType.Bottom: { hit = true; SignalsManager.Broadcast(_hitBottomBoundSignal.Name); break; } } return(hit); }
static public T GetElementForCost <T>(this IEnumerable <T> item, double cost, BoundType type, Operation <double, T> operation) { double current_cost = 0.0; T previous_item = default(T); foreach (T sub_item in item) { if (current_cost > cost) { return(type.ConvertBoundType(previous_item, sub_item)); } current_cost += operation(sub_item); previous_item = sub_item; } if (current_cost == cost) { return(previous_item); } return(type.ConvertBoundType(previous_item, default(T))); }
static public bool TryFindNearestValueByKey <KEY_TYPE, VALUE_TYPE>(this SortedList <KEY_TYPE, VALUE_TYPE> item, KEY_TYPE target_key, out VALUE_TYPE output, BoundType bound_type) where KEY_TYPE : IComparable <KEY_TYPE> { int index; if (item.TryFindNearestIndexByKey(target_key, out index, bound_type)) { output = item.Values[index]; return(true); } output = default(VALUE_TYPE); return(false); }
public void TestBoundExactValuesAllContraints() { var boundType = new BoundType <int>(true).Add(new EqualsConstraint <int>(5)).Add(new EqualsConstraint <int>(10)); Assert.Throws <ArgumentOutOfRangeException>(() => new Bound <int>(5, boundType)); }
static public IEnumerable <IEnumerable <T> > GetCostGroups <T>(this IEnumerable <T> item, double cost, BoundType type, Operation <double, T> operation) { double group_cost = 0.0; List <T> group = new List <T>(); switch (type) { case BoundType.Below: foreach (T sub_item in item) { double sub_item_cost = operation(sub_item); if (group_cost + sub_item_cost > cost) { yield return(group); group_cost = 0.0; group = new List <T>(); } group_cost += sub_item_cost; group.Add(sub_item); } break; case BoundType.Above: foreach (T sub_item in item) { group_cost += operation(sub_item); group.Add(sub_item); if (group_cost > cost) { yield return(group); group_cost = 0.0; group = new List <T>(); } } break; default: throw new UnaccountedBranchException("type", type); } if (group.IsNotEmpty()) { yield return(group); } }
public static BoundBinaryOperator Bind(SyntaxTokenKind operatorKind, BoundType leftType, BoundType rightType) => operatorKind switch {
static public int GetIndexForCost <T>(this IEnumerable <T> item, double cost, BoundType type, Operation <double, T> operation) { double current_cost = 0.0; int index = 0; foreach (T sub_item in item) { if (current_cost > cost) { break; } current_cost += operation(sub_item); index++; } if (current_cost == cost) { return(index); } return(type.ConvertBoundType(index - 1, index)); }
public BoundTypeDeclaration(BoundType boundType) : base(BoundNodeKind.TypeDeclaration) { BoundType = boundType; }
public T GetAttribute <T>() where T : Attribute { return(BoundType.GetAttribute <T>()); }
public static bool IsExclude(this BoundType @this) => Excludes.Contains(@this);
/// <summary> /// Initializes a new instance of the <see cref="Bound<T>"/> class. /// </summary> /// <param name="type">The bound type.</param> /// <param name="direction">The bound direction.</param> /// <param name="value">The bound value.</param> /// <exception cref="ArgumentException">An infinity bound must define an <see cref="P:Direction.Opened"/> direction.</exception> public Bound(BoundType type, BoundDirection direction, T value) : this(type, direction, value, true) { }
/// <summary> /// Determines if the value is within the specified range. /// </summary> /// <typeparam name="T">The type of the value.</typeparam> /// <param name="this">The source value.</param> /// <param name="bound1">The first bound for the range.</param> /// <param name="bound2">The second bound for the range.</param> /// <param name="boundType">The type of range bounds.</param> /// <returns><c>true</c> if the value is within bounds, otherwise <c>false</c>.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="this"/>, <paramref name="bound1"/>, or <paramref name="bound2"/> is <c>null</c>. /// </exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="boundType"/> is invalid.</exception> /// <example> /// <code language="csharp"> /// 10.InRange(1, 10, BoundType.ExcludeInclude); // true /// 10.InRange(10, 1, BoundType.ExcludeInclude); // true /// 10.InRange(10, 1, BoundType.IncludeExclude); // false /// 10.InRange(1, 10, BoundType.Exclude); // false /// </code> /// </example> public static bool InRange <T>([NotNull] this T @this, [NotNull] T bound1, [NotNull] T bound2, BoundType boundType) => @this.InRange(bound1, bound2, boundType, Comparer <T> .Default);
public BoundEdge(float tt, int pn, bool starting) { t = tt; primNum = pn; type = starting ? BoundType.Start : BoundType.End; }
public static Range <int> CreateOther(Range <int> range, BoundType type, Operation operation) { if (range.LowerBoundType != BoundType.CLOSED && range.LowerBoundType != BoundType.OPEN) { throw new InvalidOperationException("Unbounded lower endpoint not supported"); } if (range.UpperBoundType != BoundType.CLOSED && range.UpperBoundType != BoundType.OPEN) { throw new InvalidOperationException("Unbounded upper endpoint not supported"); } var lowerClosed = range.LowerBoundType == BoundType.CLOSED ? range.LowerEndpoint : range.LowerEndpoint + 1; var upperClosed = range.UpperBoundType == BoundType.CLOSED ? range.UpperEndpoint : range.UpperEndpoint - 1; switch (type) { case BoundType.OPEN: switch (operation) { case Operation.Precedes: return(Create(lowerClosed - 20, lowerClosed - 10, type)); case Operation.Meets: return(Create(lowerClosed - 20, lowerClosed, type)); case Operation.Overlaps: return(Create(lowerClosed - 20, lowerClosed + 1, type)); case Operation.FinishedBy: return(Create(lowerClosed - 20, upperClosed, type)); case Operation.Contains: return(Create(lowerClosed - 10, upperClosed + 10, type)); case Operation.Starts: return(Create(lowerClosed, upperClosed - 1, type)); case Operation.Equals: return(Create(lowerClosed, upperClosed, type)); case Operation.StartedBy: return(Create(lowerClosed, upperClosed + 1, type)); case Operation.During: return(Create(lowerClosed + 1, upperClosed - 1, type)); case Operation.Finishes: return(Create(lowerClosed + 1, upperClosed, type)); case Operation.OverlappedBy: return(Create(lowerClosed + 1, upperClosed + 1, type)); case Operation.MetBy: return(Create(upperClosed, upperClosed + 10, type)); case Operation.PrecededBy: return(Create(upperClosed + 10, upperClosed + 20, type)); default: throw new InvalidOperationException(); } case BoundType.CLOSED: switch (operation) { case Operation.Precedes: return(Create(lowerClosed - 20, lowerClosed - 10, type)); case Operation.Meets: return(Create(lowerClosed - 20, lowerClosed, type)); case Operation.Overlaps: return(Create(lowerClosed - 20, lowerClosed + 1, type)); case Operation.FinishedBy: return(Create(lowerClosed - 20, upperClosed, type)); case Operation.Contains: return(Create(lowerClosed - 10, upperClosed + 10, type)); case Operation.Starts: return(Create(lowerClosed, upperClosed - 1, type)); case Operation.Equals: return(Create(lowerClosed, upperClosed, type)); case Operation.StartedBy: return(Create(lowerClosed, upperClosed + 1, type)); case Operation.During: return(Create(lowerClosed + 1, upperClosed - 1, type)); case Operation.Finishes: return(Create(lowerClosed + 1, upperClosed, type)); case Operation.OverlappedBy: return(Create(lowerClosed + 1, upperClosed + 1, type)); case Operation.MetBy: return(Create(upperClosed, upperClosed + 10, type)); case Operation.PrecededBy: return(Create(upperClosed + 10, upperClosed + 20, type)); default: throw new InvalidOperationException(); } default: throw new InvalidOperationException("This method only supports OPEN and CLOSED ranges"); } }
/// <summary> /// Initializes a new instance of the <see cref="GeneralError"/> class. /// </summary> /// <param name="item">The item.</param> /// <param name="type">The type.</param> /// <param name="message">The message.</param> public GeneralError(IElement item, BoundType type, string message) { Element = item; Type = type; Message = message; }
public void TryToAttachDefinitelyTest(Molecule mTo, Molecule mAttach, int boundNr_expected, BoundType boudType_expected) { mAttach.TryToAttachDefinitely(mTo); Assert.AreEqual(boundNr_expected, mTo.GetBoundNr(mAttach)); Assert.AreEqual(boundNr_expected, mAttach.GetBoundNr(mTo)); Assert.AreEqual(boudType_expected, mAttach.BoundType); var poz_expected = mTo.BoundPosition(boundNr_expected); AssertExtensions.AreAlmostEqual(poz_expected, mAttach.Position); // Assert.AreEqual(tetraNr_expected, mAttach.Position.TetrahedronPart(mTo.Position)); }
public static List<FuzzyVariable> Stretch( List<MeasurementWithResult> learningSet, DecisionMakerType1 originalDecisionMaker, VariableMFParam toStretch, BoundType boundType) { List<MeasurementWithResult> withResultsFromFs = (from measurement in learningSet select new MeasurementWithResult { InputValues = new Dictionary<string, double>(measurement.InputValues), OutputString = originalDecisionMaker.InferTerm(measurement.InputValues) }).ToList(); double multiplier = 1; int error = 0; bool canStretchMore = true; if (boundType == BoundType.Upper) { while (error == 0 && canStretchMore) { multiplier += 0.001; MamdaniFuzzySystem newFuzzySystem = UpdateParamsByMultiplier( originalDecisionMaker, multiplier, toStretch, out canStretchMore); var updatedDecisionMaker = new DecisionMakerType1(newFuzzySystem, originalDecisionMaker.RulesDefinitions); error = (from measurement in withResultsFromFs where updatedDecisionMaker.InferTerm(measurement.InputValues) != measurement.OutputString select measurement).Count(); } multiplier -= 0.001; var finalFuzzySystem = UpdateParamsByMultiplier( originalDecisionMaker, multiplier, toStretch, out canStretchMore); return finalFuzzySystem.Input; } else { while (error == 0 && canStretchMore) { multiplier -= 0.001; MamdaniFuzzySystem newFuzzySystem = UpdateParamsByMultiplier( originalDecisionMaker, multiplier, toStretch, out canStretchMore); var updatedDecisionMaker = new DecisionMakerType1(newFuzzySystem, originalDecisionMaker.RulesDefinitions); error = (from measurement in withResultsFromFs where updatedDecisionMaker.InferTerm(measurement.InputValues) != measurement.OutputString select measurement).Count(); } multiplier += 0.001; var finalFuzzySystem = UpdateParamsByMultiplier( originalDecisionMaker, multiplier, toStretch, out canStretchMore); return finalFuzzySystem.Input; } }
public static BoundType Combine(this BoundType x, BoundType y) => x >= y ? x : y;
void OnGUI() { EditorGUILayout.BeginVertical(); EditorGUI.BeginChangeCheck(); _boundType = (BoundType)EditorGUILayout.EnumPopup("Bound Type", _boundType); switch (_boundType) { case BoundType.Box2D: _box.position = EditorGUILayout.Vector3Field("position", _box.position); _box.size = EditorGUILayout.Vector2Field("Scale", _box.size); _box.rotate_y = EditorGUILayout.Slider("rotate Y angle", _box.rotate_y, 0f, 360f); break; case BoundType.AABox3D: _aaBox.Position = EditorGUILayout.Vector3Field("position", _aaBox.Position); _aaBox.Size = EditorGUILayout.Vector3Field("Scale", _aaBox.Size); break; case BoundType.Cube: _cube.position = EditorGUILayout.Vector3Field("position", _cube.position); _cube.size = EditorGUILayout.Vector3Field("Scale", _cube.size); _cube.rotate.y = EditorGUILayout.Slider("Rotate Y angle", _cube.rotate.y, 0f, 360f); break; case BoundType.Circle: _circle.position = EditorGUILayout.Vector3Field("position", _circle.position); _circle.radius = EditorGUILayout.FloatField("radius", _circle.radius); break; case BoundType.Capsule: _capsule.position = EditorGUILayout.Vector3Field("position", _capsule.position); _capsule.radius = EditorGUILayout.FloatField("radius", _capsule.radius); _capsule.height = EditorGUILayout.FloatField("height", _capsule.height); break; case BoundType.Sector: _sector.position = EditorGUILayout.Vector3Field("position", _sector.position); _sector.radius = EditorGUILayout.FloatField("radius", _sector.radius); _sector.angle = EditorGUILayout.Slider("Sector Angle", _sector.angle, 0f, 360f); _sector.rotate_y = EditorGUILayout.Slider("Rotate Y angle", _sector.rotate_y, 0f, 360f); break; } if (EditorGUI.EndChangeCheck()) { //Calculate(); SceneView.RepaintAll(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical("box"); _testMode = (TestMode)EditorGUILayout.EnumPopup("Test Mode", _testMode); //if (_testMode != TestMode.None) if (_testMode == TestMode.Dot2D || _testMode == TestMode.Line2D || _testMode == TestMode.Ray2D) { EditorGUILayout.BeginHorizontal(); _currentClickedPos = EditorGUILayout.Vector3Field("Clicked Pos A", _currentClickedPos); GUIStyle gs = new GUIStyle("button"); if (_clickMode_cur) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_cur = !_clickMode_cur; } EditorGUILayout.EndHorizontal(); if (_testMode == TestMode.Line2D || _testMode == TestMode.Ray2D) { EditorGUILayout.BeginHorizontal(); _prevClickedPos = EditorGUILayout.Vector3Field("Clicked Pos B", _prevClickedPos); if (_clickMode_prev) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_prev = !_clickMode_prev; } EditorGUILayout.EndHorizontal(); } } else if (_testMode == TestMode.Box2D) { EditorGUILayout.BeginHorizontal(); _currentClickedPos = EditorGUILayout.Vector3Field("Box Pos", _currentClickedPos); GUIStyle gs = new GUIStyle("button"); if (_clickMode_cur) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_cur = !_clickMode_cur; } EditorGUILayout.EndHorizontal(); _testBox.position = _currentClickedPos; _testBox.size = EditorGUILayout.Vector2Field("Box Size", _testBox.size); _testBox.rotate_y = EditorGUILayout.Slider("Box Rotate Y angle", _testBox.rotate_y, 0f, 360f); } else if (_testMode == TestMode.AABox3D) { EditorGUILayout.BeginHorizontal(); _currentClickedPos = EditorGUILayout.Vector3Field("Box Pos", _currentClickedPos); GUIStyle gs = new GUIStyle("button"); if (_clickMode_cur) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_cur = !_clickMode_cur; } EditorGUILayout.EndHorizontal(); _testAABox.Position = _currentClickedPos; _testAABox.Size = EditorGUILayout.Vector3Field("Box Size", _testAABox.Size); } else if (_testMode == TestMode.LerpBox2D) { EditorGUILayout.BeginHorizontal(); _currentClickedPos = EditorGUILayout.Vector3Field("Clicked Pos A", _currentClickedPos); GUIStyle gs = new GUIStyle("button"); if (_clickMode_cur) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_cur = !_clickMode_cur; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _prevClickedPos = EditorGUILayout.Vector3Field("Clicked Pos B", _prevClickedPos); if (_clickMode_prev) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_prev = !_clickMode_prev; } EditorGUILayout.EndHorizontal(); _lerpBoxSize = EditorGUILayout.Vector2Field("Box Size (X:width Y:height)", _lerpBoxSize); _lerpTweenFactor = EditorGUILayout.Slider("Tween Factor", _lerpTweenFactor, 0f, 1f); _lerpElapsedTime = EditorGUILayout.FloatField("Elapsed Time (millisec)", _lerpElapsedTime); Vector3 direction = (_prevClickedPos - _currentClickedPos).normalized; Vector3 end = _prevClickedPos - (direction * _lerpBoxSize.y * 0.5f); Vector3 lerpPosition = Vector3.Lerp(_currentClickedPos + (direction * _lerpBoxSize.y * 0.5f), end, _lerpTweenFactor); float totLength = (lerpPosition - end).magnitude; float elapsedLength = (_lerpElapsedTime * 0.001f) > totLength ? totLength : _lerpElapsedTime * 0.001f; Vector3 elapsedPosition = lerpPosition + (direction * elapsedLength); float lerpLength = elapsedLength + _lerpBoxSize.y; _testBox.position = Vector3.Lerp(lerpPosition, elapsedPosition, 0.5f); _testBox.size.x = _lerpBoxSize.x; _testBox.size.y = _lerpBoxSize.y > lerpLength ? _lerpBoxSize.y : lerpLength; _testBox.rotate_y = Mathf.Acos(Vector3.Dot(direction, Vector3.forward)) * Mathf.Rad2Deg * (direction.x > 0f ? 1 : -1); EditorGUILayout.LabelField("angle", _testBox.rotate_y.ToString()); } else if (_testMode == TestMode.Triangle) { } else if (_testMode == TestMode.Sector2D) { EditorGUILayout.BeginHorizontal(); _currentClickedPos = EditorGUILayout.Vector3Field("Sector Pos", _currentClickedPos); GUIStyle gs = new GUIStyle("button"); if (_clickMode_cur) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_cur = !_clickMode_cur; } EditorGUILayout.EndHorizontal(); _testSector.position = _currentClickedPos; _testSector.radius = EditorGUILayout.FloatField("Sector Radius", _testSector.radius); _testSector.angle = EditorGUILayout.Slider("Sector Angle", _testSector.angle, 0f, 360f); _testSector.rotate_y = EditorGUILayout.Slider("Sector Rotate Y Angle", _testSector.rotate_y, 0f, 360f); } else if (_testMode == TestMode.Circle2D) { EditorGUILayout.BeginHorizontal(); _currentClickedPos = EditorGUILayout.Vector3Field("Circle Pos", _currentClickedPos); GUIStyle gs = new GUIStyle("button"); if (_clickMode_cur) { gs.normal.textColor = Color.green; } else { gs.normal.textColor = Color.red; } if (GUILayout.Button("Edit", gs, GUILayout.Height(32f))) { _clickMode_cur = !_clickMode_cur; } EditorGUILayout.EndHorizontal(); _testCircle.position = _currentClickedPos; _testCircle.radius = EditorGUILayout.FloatField("Circle Size", _testCircle.radius); } EditorGUILayout.EndVertical(); bool isIn = false; switch (_boundType) { case BoundType.Box2D: switch (_testMode) { case TestMode.Dot2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DDot(_box, new Vector2(_currentClickedPos.x, _currentClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Line2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DLine(_box, new Vector2(_currentClickedPos.x, _currentClickedPos.z), new Vector2(_prevClickedPos.x, _prevClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Ray2D: Vector2 dir = new Vector2(_prevClickedPos.x, _prevClickedPos.z) - new Vector2(_currentClickedPos.x, _currentClickedPos.z); EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DRay(_box, new Vector2(_currentClickedPos.x, _currentClickedPos.z), dir)) ? "Yes" : "No"); break; case TestMode.Box2D: case TestMode.LerpBox2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DBox(_box, _testBox)) ? "Yes" : "No"); break; case TestMode.Circle2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DCircle(_box, _testCircle)) ? "Yes" : "No"); break; } break; case BoundType.Cube: switch (_testMode) { case TestMode.Dot2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DDot(_cube.Get2Dbox(), new Vector2(_currentClickedPos.x, _currentClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Line2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DLine(_cube.Get2Dbox(), new Vector2(_currentClickedPos.x, _currentClickedPos.z), new Vector2(_prevClickedPos.x, _prevClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Ray2D: Vector2 dir = new Vector2(_prevClickedPos.x, _prevClickedPos.z) - new Vector2(_currentClickedPos.x, _currentClickedPos.z); EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DRay(_cube.Get2Dbox(), new Vector2(_currentClickedPos.x, _currentClickedPos.z), dir)) ? "Yes" : "No"); break; case TestMode.Box2D: case TestMode.LerpBox2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DBox(_cube.Get2Dbox(), _testBox)) ? "Yes" : "No"); break; case TestMode.Circle2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DCircle(_cube.Get2Dbox(), _testCircle)) ? "Yes" : "No"); break; } break; case BoundType.Circle: switch (_testMode) { case TestMode.Dot2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DDot(_circle, new Vector2(_currentClickedPos.x, _currentClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Line2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DLine(_circle, new Vector2(_currentClickedPos.x, _currentClickedPos.z), new Vector2(_prevClickedPos.x, _prevClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Ray2D: Vector2 dir = new Vector2(_prevClickedPos.x, _prevClickedPos.z) - new Vector2(_currentClickedPos.x, _currentClickedPos.z); EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DRay(_circle, new Vector2(_currentClickedPos.x, _currentClickedPos.z), dir)) ? "Yes" : "No"); break; case TestMode.Box2D: case TestMode.LerpBox2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DBox(_circle, _testBox)) ? "Yes" : "No"); break; case TestMode.Circle2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DCircle(_circle, _testCircle)) ? "Yes" : "No"); break; case TestMode.Sector2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DSector(_circle, _testSector)) ? "Yes" : "No"); break; } break; case BoundType.Capsule: switch (_testMode) { case TestMode.Dot2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DDot(_capsule.GetCircle(), new Vector2(_currentClickedPos.x, _currentClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Line2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DLine(_capsule.GetCircle(), new Vector2(_currentClickedPos.x, _currentClickedPos.z), new Vector2(_prevClickedPos.x, _prevClickedPos.z))) ? "Yes" : "No"); break; case TestMode.Ray2D: Vector2 dir = new Vector2(_prevClickedPos.x, _prevClickedPos.z) - new Vector2(_currentClickedPos.x, _currentClickedPos.z); EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DRay(_capsule.GetCircle(), new Vector2(_currentClickedPos.x, _currentClickedPos.z), dir)) ? "Yes" : "No"); break; case TestMode.Box2D: case TestMode.LerpBox2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DBox(_capsule.GetCircle(), _testBox)) ? "Yes" : "No"); break; case TestMode.Circle2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DCircle(_capsule.GetCircle(), _testCircle)) ? "Yes" : "No"); break; case TestMode.Sector2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DSector(_capsule.GetCircle(), _testSector)) ? "Yes" : "No"); break; } break; case BoundType.Sector: switch (_testMode) { case TestMode.Dot2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DSector(new Vector2(_currentClickedPos.x, _currentClickedPos.z), _sector)) ? "Yes" : "No"); break; case TestMode.Line2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DSector(new Vector2(_currentClickedPos.x, _currentClickedPos.z), new Vector2(_prevClickedPos.x, _prevClickedPos.z), _sector)) ? "Yes" : "No"); break; case TestMode.Box2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DSector(_testBox, _sector)) ? "Yes" : "No"); break; case TestMode.Circle2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DSector(_testCircle, _sector)) ? "Yes" : "No"); break; case TestMode.Sector2D: EditorGUILayout.LabelField("In ?", (isIn = ZKit.Math.Geometry.Collision2D.CollisionDetect2DSector(_testSector, _sector)) ? "Yes" : "No"); break; } break; } if (isIn) { _lineColor = Color.green; } else { _lineColor = Color.red; } EditorGUILayout.Separator(); EditorGUILayout.EndVertical(); }
private BoundBinaryOperator(BoundBinaryOperatorKind kind, BoundType type) : this(kind, type, type, type) { }
public Bound(Value left, BoundType type, Value right) { Left = left; BoundType = type; Right = right; }
private BoundBinaryOperator(BoundBinaryOperatorKind kind, BoundType leftType, BoundType rightType, BoundType returnType) { Kind = kind; LeftType = leftType; RightType = rightType; ReturnType = returnType; }
static public VALUE_TYPE FindNearestValueByKey <KEY_TYPE, VALUE_TYPE>(this SortedList <KEY_TYPE, VALUE_TYPE> item, KEY_TYPE target_key, BoundType bound_type) where KEY_TYPE : IComparable <KEY_TYPE> { VALUE_TYPE output; item.TryFindNearestValueByKey(target_key, out output, bound_type); return(output); }
/// <summary> /// Retrieve the maximum coordinates for each axis from a transform list /// </summary> /// <param name="referencePosition"> /// The first position to be used as a reference, in a <see cref="Vector3"/> /// </param> /// <param name="transformList"> /// The <see cref="Transform[]"/> to retrieve position from /// </param> /// <returns> /// The maximum extents in a <see cref="Vector3"/> /// </returns> public static Vector3 GetMaxMarkPosition(Vector3 referencePosition, Transform[] transformList, BoundType type) { switch (type) { case BoundType.Collider: return(ColliderExtents.GetMaxMarkPosition(referencePosition, transformList)); case BoundType.Renderer: return(RendererExtents.GetMaxMarkPosition(referencePosition, transformList)); default: return(BasicExtents.GetMaxMarkPosition(referencePosition, transformList)); } }
private void UpdateMemberships(List<FuzzyVariable> sourceVariables, VariableMFParam parameterToUpdate, BoundType boundType) { switch (parameterToUpdate) { case VariableMFParam.Mean: case VariableMFParam.Deviation: foreach (var variable in inputVariables) { foreach (var type2term in variable.Terms) { var sourceTerm = sourceVariables.Find(v => v.Name == variable.Name).Terms.Find(t => t.Name == type2term.Name); var mf = sourceTerm.MembershipFunction as NormalMembershipFunction; if (boundType == BoundType.Lower) { type2term.LowerMembershipFunction = new NormalMembershipFunction(mf.B, mf.Sigma); } else { type2term.UpperMembershipFunction = new NormalMembershipFunction(mf.B, mf.Sigma); } } } break; case VariableMFParam.RuleWeight: // todo break; } }