public NodeVector nodes() { NodeVector ret = new NodeVector(NQuantLibcPINVOKE.PiecewiseLinearZero_nodes(swigCPtr), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public NodeVector nodes() { NodeVector ret = new NodeVector(NQuantLibcPINVOKE.HazardRateCurve_nodes(swigCPtr), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public NodeVector GetRange(int index, int count) { global::System.IntPtr cPtr = NQuantLibcPINVOKE.NodeVector_GetRange(swigCPtr, index, count); NodeVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new NodeVector(cPtr, true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static NodeVector Repeat(NodePair value, int count) { global::System.IntPtr cPtr = NQuantLibcPINVOKE.NodeVector_Repeat(NodePair.getCPtr(value), count); NodeVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new NodeVector(cPtr, true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public void Copy(NodeVector path, int count) { Debug.Assert(tree == path.tree); indexStack.Clear(); nodeStack.Clear(); for (int ix = 0; ix < count; ++ix) { indexStack.Add(path.indexStack[ix]); nodeStack.Add(path.nodeStack[ix]); } }
public void Update() { if (inputReceived) { for (int i = 0; i < cCollidable.collidedThisFrame.Count; i++) { NodeVector cNodeVector = cCollidable.collidedThisFrame[i].GetComponent <NodeVector>(); if (cNodeVector) { cNodeVector.forceVector = cInertia.inertia; cNodeVector.isUpdated = true; } } } }
// On exit: path is left-edge normalized. public static NodeVector CreateFromOffset(NodeVector path, int offset) { Debug.Assert(offset >= 0); var result = new NodeVector(path, path.Height); int level = path.Height - 1; var leaf = (Leaf)result.nodeStack[level]; int rix = leaf.KeyCount - result.indexStack[level]; if (rix >= offset) { result.indexStack[level] += offset; return(result); } offset -= rix; while (--level >= 0) { var bh = (Branch)result.nodeStack[level]; for (int ix = result.indexStack[level] + 1; ix <= bh.KeyCount;) { Node node = bh.GetChild(ix); int wt = node.Weight; if (wt < offset) { ++ix; offset -= wt; } else { result.indexStack[level] = ix; result.nodeStack[level] = bh; ++level; if (node is Leaf) { result.nodeStack[level] = node; result.indexStack[level] = offset; return(result); } ix = 0; bh = (Branch)node; } } } return(null); }
/// <summary>Adds a supplied number of occurrences of the supplied item to the bag.</summary> /// <param name="item">The item to add.</param> /// <param name="count">The number of copies to add.</param> /// <returns><b>true</b> if <em>item</em> was not already in the bag; otherwise <b>false</b>.</returns> /// <remarks> /// <para> /// If the supplied item already occurs in the bag /// then the new item is added sequentially following the old items. /// </para> /// <para> /// This is a O(<em>m</em> log <em>n</em>) operation /// where <em>m</em> is <em>count</em> and <em>n</em> is <see cref="Count"/>. /// </para> /// </remarks> /// <exception cref="ArgumentException">When <em>count</em> is less than zero.</exception> public bool Add(T item, int count) { if (count < 0) { throw new ArgumentException("Must be non-negative.", nameof(count)); } var path = new NodeVector(this, item); bool result = path.IsFound; if (count > 0) { for (;;) { int leafAdds = maxKeyCount - path.TopNode.KeyCount; if (leafAdds == 0) { AddKey(item, path); --count; } else { if (leafAdds > count) { leafAdds = count; } path.TopNode.InsertKey(path.TopIndex, item, leafAdds); path.ChangePathWeight(leafAdds); count -= leafAdds; } if (count == 0) { break; } path = new NodeVector(this, item); } } return(result); }
private void Visualise() { NodeVector cNodeVector = gameObject.GetComponent <NodeVector>(); cLineRenderer.SetPositions(new Vector3[] { transform.position, transform.position + cNodeVector.forceVector }); float percentageOfMaximum = cNodeVector.forceVector.sqrMagnitude / cNodeVector.maxSqrMagnitude; if (percentageOfMaximum > cNodeVectorVisual.strongThreshold) { cLineRenderer.material = cNodeVectorVisual.strongMaterial; } if (percentageOfMaximum <= cNodeVectorVisual.strongThreshold) { cLineRenderer.material = cNodeVectorVisual.mediumMaterial; } if (percentageOfMaximum <= cNodeVectorVisual.weakThreshold) { cLineRenderer.material = cNodeVectorVisual.weakMaterial; } }
private void OnTriggerEnter(Collider collider) { NodeVector cNodeVector = collider.gameObject.GetComponent <NodeVector>(); if (cNodeVector) { Vector3 newInertia = new Vector3(); if (cNodeVector.additive) { newInertia = cBallInertia.inertia * cBallNodeReactor.inertiaWeight + cNodeVector.forceVector * cBallNodeReactor.nodeWeight; } else { newInertia = cNodeVector.forceVector.normalized * cBallInertia.inertia.magnitude; } cBallInertia.inertia = Vector3.ClampMagnitude(newInertia, cBallInertia.maxSqrMagVelocity); } }
public NodeVector nodes() { NodeVector ret = new NodeVector(NQuantLibcPINVOKE.PiecewiseFlatForward_nodes(swigCPtr), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public NodeVector nodes() { NodeVector ret = new NodeVector(NQuantLibcPINVOKE.DiscountCurve_nodes(swigCPtr), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static NodeVector CreateFromIndex(Btree <T> tree, int index) { Debug.Assert(index <= tree.root.Weight); var path = new NodeVector(tree); if (index == 0) { for (Node n0 = tree.root;;) { path.indexStack.Add(0); path.nodeStack.Add(n0); if (n0 is Branch bh) { n0 = bh.GetChild(0); } else { return(path); } } } else if (index >= tree.root.Weight) { for (Node n0 = tree.root;;) { path.indexStack.Add(n0.KeyCount); path.nodeStack.Add(n0); if (n0 is Branch bh) { n0 = bh.GetChild(bh.KeyCount); } else { return(path); } } } Node node = tree.root; while (node is Branch branch) { for (int ix = 0; ; ++ix) { Debug.Assert(ix <= node.KeyCount); Node child = branch.GetChild(ix); int cw = child.Weight; if (cw > index) { path.indexStack.Add(ix); path.nodeStack.Add(node); node = child; break; } index -= cw; } } path.indexStack.Add(index); path.nodeStack.Add(node); return(path); }
public SparseGraph() { Nodes = new NodeVector(); nextNodeIndex = 0; }
public NodeVector(NodeVector other) : this(NQuantLibcPINVOKE.new_NodeVector__SWIG_1(NodeVector.getCPtr(other)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(NodeVector obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
private void Start() { cBelongsToNodeVector = cNodeParticle.belongsToNodeObject.GetComponent <NodeVector>(); AlignParticle(); }