private void rightAlignTextFields() { int rightLoc; if (message != null) { rightLoc = HMath.Max(this.name.Location.X, this.location.Location.X, Time.Location.X, EType.Location.X, message.Location.X); } else { rightLoc = HMath.Max(this.name.Location.X, this.location.Location.X, Time.Location.X, EType.Location.X, messagePic.Location.X); } name.Location = new Point(rightLoc, this.name.Location.Y); location.Location = new Point(rightLoc, this.location.Location.Y); Time.Location = new Point(rightLoc, Time.Location.Y); EType.Location = new Point(rightLoc, EType.Location.Y); if (message != null) { message.Location = new Point(rightLoc, message.Location.Y); } else { messagePic.Location = new Point(rightLoc, messagePic.Location.Y); } }
/** 打飞 */ public void HitFly() { if (unitData.unitType == UnitType.Solider) { SteeringAgentComponent m_steeringAgent = GetComponent <SteeringAgentComponent>(); m_steeringAgent.StopSteering(); if (transform.position != unitData.hitFlyPoint) { Vector3 dir = (unitData.hitFlyPoint - transform.position).normalized; unitAgent.angel = HMath.AngleBetweenForward2Vector(dir); } else { unitData.hitFlyPoint += (unitData.to.unit.transform.position - transform.position).normalized * 3f; } Rigidbody rigidbody = GetComponent <Rigidbody>(); rigidbody.useGravity = true; rigidbody.AddExplosionForce(unitData.hitFlyPower, unitData.hitFlyPoint, unitData.hitFlyPowerRadius, unitData.hitFlyPowerUp); unitAgent.action = "die"; // BSolider_Alpha_Hide soliderAlphaHide = GetComponent<BSolider_Alpha_Hide>(); // soliderAlphaHide.enabled = true; // Collider collider = GetComponent<Collider>(); // collider.enabled = true; } }
/// <summary> /// Получение суммы по столбцу /// </summary> /// <param name="indxCol">индекс столбца</param> /// <returns>сумма по столбцу</returns> private double summaColumnValues(int indxCol, out int counter) { counter = 0; double dblRes = 0F; try { foreach (DataGridViewRow row in Rows) { if (row.Index < Rows.Count - 1) { // все кроме крайней строки if ((!(row.Cells[indxCol].Value == null)) && (string.IsNullOrEmpty(row.Cells[indxCol].Value.ToString()) == false)) { // только, если есть значение для разбора dblRes += HMath.doubleParse(row.Cells[indxCol].Value.ToString()); counter++; } else { ; } } else { ; } } } catch (Exception e) { Logging.Logg().Exception(e, string.Format(@"PanelTaskVedomostBl::summaColumnValues () - суммирования столбца №{0}...", indxCol), Logging.INDEX_MESSAGE.NOT_SET); } return(dblRes); }
/// <summary> /// Установить содержание для запроса /// </summary> protected override void setQuery() { int idReq = HMath.GetRandomNumber() , i = -1; string cmd = string.Empty; //перевод даты для суточного набора if (DateTimeStart != DateTimeBegin) { DateTimeBegin = (DateTimeBegin - DateTimeBegin.TimeOfDay).AddHours(23); } else { DateTimeBegin = (DateTimeStart - DateTimeStart.TimeOfDay).AddHours(-1); } //Формировать запрос i = 0; m_strQuery = "SELECT ДатаВремя, "; foreach (GroupSignalsVzletNativeDSql.SIGNALMSTKKSNAMEsql s in m_arSignals) { m_strQuery += s.m_kks_name + ", "; } m_strQuery = m_strQuery.Remove(m_strQuery.Length - 2, 1); m_strQuery += " FROM " + NameTable + " "; m_strQuery += @"WHERE ДатаВремя > '" + DateTimeBegin + "' and ДатаВремя <= '" + DateTimeBegin.AddSeconds(PeriodMain.TotalSeconds) + "'"; //DateTimeBegin = DateTimeBegin.AddSeconds(secUTCOffsetToData); }
public static double Corr(Vector bfactor1, Vector bfactor2, bool ignore_nan = false) { double hcorr = HMath.HCorr(bfactor1, bfactor2, ignore_nan); if (HDebug.IsDebuggerAttached) { double corr = double.NaN; using (new Matlab.NamedLock("CORR")) { Matlab.Clear("CORR"); Matlab.PutVector("CORR.bfactor1", bfactor1); Matlab.PutVector("CORR.bfactor2", bfactor2); if (ignore_nan) { Matlab.Execute("CORR.idxnan = isnan(CORR.bfactor1) | isnan(CORR.bfactor2);"); Matlab.Execute("CORR.bfactor1 = CORR.bfactor1(~CORR.idxnan);"); Matlab.Execute("CORR.bfactor2 = CORR.bfactor2(~CORR.idxnan);"); } if (Matlab.GetValueInt("min(size(CORR.bfactor1))") != 0) { corr = Matlab.GetValue("corr(CORR.bfactor1, CORR.bfactor2)"); } Matlab.Clear("CORR"); } if ((double.IsNaN(hcorr) && double.IsNaN(corr)) == false) { HDebug.AssertTolerance(0.00000001, hcorr - corr); } //HDebug.ToDo("use HMath.HCorr(...) instead"); } return(hcorr); }
/// <summary> /// Заполнение массива данными /// </summary> /// <param name="dgvActive">активное отображение данных</param> private void fillToArray(DataGridView dgvActive) { arrayData = new object[dgvActive.RowCount, dgvActive.ColumnCount - 1]; int indexArray = -1; for (int i = 0; i < dgvActive.Rows.Count; i++) { indexArray = 0; arrayData[i, indexArray++] = dgvActive.Rows[i].Tag.ToString(); for (int j = 0; j < dgvActive.Columns.Count; j++) { //if (j >= ((int)DataGridViewVedomostBl.INDEX_SERVICE_COLUMN.COUNT - 1)) { //if (j > ((int)DataGridViewVedomostBl.INDEX_SERVICE_COLUMN.COUNT - 1)) arrayData[i, indexArray] = //s_VedCalculate.AsParseToF HMath.doubleParse (dgvActive.Rows[i].Cells[j].Value.ToString()); } //else //??? получить дату // arrayData[i, indexArray] = dgvActive.Rows[i].Cells[j].Value.ToString(); indexArray++; //} else // ; } }
public void SetAroundPoint(Vector3 point, Vector3 buildPoint) { state = UnitPathState.Around; aroundPoint = point; Vector3 d1 = point - buildPoint; Vector3 d2 = transform.position - buildPoint; float d = Vector3.Dot(d1.normalized, d2.normalized); // Debug.Log("SetAroundPoint point=" + point + " d=" + d); Vector3[] points = null; if (d < 0) { Vector3 inPoint = HMath.IntersectionPoint(buildPoint, transform.position, point); Vector3 p = buildPoint + (inPoint - buildPoint).normalized * aroundRadius; points = new Vector3[] { transform.position, p, point }; } else { points = new Vector3[] { transform.position, point }; } aroundPoints = points; // m_steeringAgent.SteerAlongPath(points, m_pathAgent.PathManager.PathTerrain ); m_steeringAgent.SteerAlongPath(points, null); }
/// <summary> /// Finds the least common sector between a set of <see cref="WorldPoint"/>s. /// </summary> /// <param name="points">The set of <see cref="WorldPoint"/>s.</param> /// <returns>A new <see cref="WorldPoint"/>, located at the origin of the least common sector.</returns> public static WorldPoint LeastCommonSector(params WorldPoint[] points) { if (points != null && points.Length > 0) { int[] x = new int[points.Length]; int[] y = new int[points.Length]; for (int i = 0; i < points.Length; i++) { x[i] = points[i].X.Sector; y[i] = points[i].Y.Sector; } int xSec = HMath.Min(x); int ySec = HMath.Min(y); return(new WorldPoint(new WorldCoordinate(xSec, 0), new WorldCoordinate(ySec, 0))); } else { Log.Error("couldn't find least common sector: WorldPoint array is null or 0-length"); } return(WorldPoint.Zero); }
/// <summary> /// Установить содержание для запроса /// </summary> protected override void setQuery() { int idReq = HMath.GetRandomNumber() , i = -1; string cmd = string.Empty; long secUTCOffsetToData = m_msecUTCOffsetToServer / 1000; //перевод даты для суточного набора if (DateTimeStart != DateTimeBegin) { DateTimeBegin = (DateTimeBegin - DateTimeBegin.TimeOfDay).AddDays(PeriodMain.Days); } else { DateTimeBegin = (DateTimeStart - DateTimeStart.TimeOfDay); } //Формировать запрос i = 0; foreach (GroupSignalsKTSTUDsql.SIGNALIdsql s in m_arSignals) { if (s.IsFormula == false) { if (i == 0) { cmd = @"List"; } else if (i == 1) { cmd = @"ListAdd"; } m_strQuery += @"exec e6work.dbo.ep_AskVTIdata @cmd='" + cmd + @"'," + @"@idVTI=" + s.m_iIdLocal + @"," + @"@TimeStart='" + DateTimeBeginFormat + @"'," + @"@TimeEnd='" + DateTimeEndFormat + @"'," + @"@idReq=" + idReq + @";"; i++; } else { // формула ; } } m_strQuery += @"SELECT idVTI as [ID],idReq,TimeIdx,TimeRTC, DATEADD(Second," + secUTCOffsetToData + ",TimeSQL) as [DATETIME],idState,ValueFl as [VALUE],ValueInt,IsInteger,idUnit" + @", DATEDIFF(HH, GETDATE(), GETUTCDATE()) as [UTC_OFFSET]" + @" FROM e6work.dbo.VTIdataList" + @" WHERE idReq=" + idReq + @";"; m_strQuery += @"exec e6work.dbo.ep_AskVTIdata @cmd='" + @"Clear" + @"'," + @"@idReq=" + idReq + @";"; }
/** 直线与圆相交。圆半径和直线的相交点 */ public static Vector3 IntersectionPoint(Vector3 point, Vector3 hit, float radius, Vector3 lineFrom, Vector3 lineTo) { float c = radius; float a = HMath.distance(point, lineFrom, lineTo); float b = Mathf.Sqrt(c * c - a * a); return(hit + (lineTo - lineFrom).normalized * b); }
Vector3 Extended(Vector3 from, Vector3 to) { Vector3 point = Vector3.zero; point.x = HMath.directionPointX(from.x, from.z, to.x, to.z, extended); point.z = HMath.directionPointY(from.x, from.z, to.x, to.z, extended); return(point); }
IEnumerator addForceParabolaGo(Vector3 srcPos, float skillRange) { float idxRand = Random.Range(0, 0.2f); yield return(new WaitForSeconds(idxRand)); float currentDist = Vector3.Distance(this.transform.position, srcPos); float randValue = Random.Range(0, 5.0f); // print("==="+ randValue); Vector3 t = (transform.position - srcPos).normalized; m_endPos = srcPos + (transform.position - srcPos).normalized * (currentDist + trackParam.range + randValue); m_endPos.y = transform.position.y; m_endPos2 = m_endPos + (transform.position - srcPos).normalized * (trackParam.range / 4); m_endPos2.y = transform.position.y; //直接散开 float idxDis = Random.Range(0, 1.0f); m_pathAll[0] = transform.position; m_pathAll[1] = new Vector3((m_endPos.x - transform.position.x) / 2 + transform.position.x, trackParam.high + idxDis, (m_endPos.z - transform.position.z) / 2 + transform.position.z + idxDis); m_pathAll[2] = m_endPos; //计算角度 Vector3 a = new Vector3(0, 0, 1); Vector3 b = transform.position - srcPos; float angle = HMath.angle(0, 0, b.z, b.x); Hashtable args = new Hashtable(); //设置路径的点 args.Add("path", m_pathAll); //设置类型为线性,线性效果会好一些。 //args.Add("easeType", iTween.EaseType.easeOutQuad); args.Add("easeType", iTween.EaseType.linear); //设置寻路的速度 args.Add("speed", trackParam.speedTrack); //args.Add("delay", 0.2f); //是否先从原始位置走到路径中第一个点的位置 // args.Add("movetopath", true); //是否让模型始终面朝当面目标的方向,拐弯的地方会自动旋转模型 //如果你发现你的模型在寻路的时候始终都是一个方向那么一定要打开这个 //args.Add("orienttopath", true); //处理移动过程中的事件。 //开始发生移动时调用AnimationStart方法,5.0表示它的参数 args.Add("onstart", "AnimationStart"); args.Add("onstartparams", angle); //移动结束时调用,参数和上面类似 args.Add("oncomplete", "AnimationEnd"); args.Add("oncompleteparams", "end"); args.Add("oncompletetarget", gameObject); //移动中调用,参数和上面类似 //args.Add("onupdate", "AnimationUpdate"); //args.Add("onupdatetarget", gameObject); //args.Add("onupdateparams", true); //让模型开始寻路 iTween.MoveTo(this.gameObject, args); }
public bool CheckModeWithHess(MatrixByArr hess, double[] masses, ILinAlg la, Mode[] modes = null, double tolerance = 0.00001) { if (modes == null) { modes = ToModes(masses); } HessMatrix ohess = new HessMatrixDense { hess = modes.GetHessian(masses, la), }; double corr = HMath.HCorr(hess.ToArray().HToArray1D(), ohess.ToArray().HToArray1D()); System.Console.Write("corr(TestHess,HessVibr:{0} ", corr); { HDebug.Assert(hess.ColSize == ohess.ColSize); HDebug.Assert(hess.RowSize == ohess.RowSize); double ltolerance = hess.ToArray().HAbs().HMax() * tolerance; ltolerance = tolerance; for (int c = 0; c < ohess.ColSize; c++) { for (int r = 0; r < ohess.RowSize; r++) { double v = hess[c, r]; double mwv = ohess[c, r]; double diff = Math.Abs(v - mwv); if (diff >= ltolerance) { return(false); } } } } //{ // Matrix vhess = hess / hess.ToArray().HToArray1D().HVar(); // Matrix vohess = ohess / ohess.ToArray().HToArray1D().HVar(); // // HDebug.Assert(hess.ColSize == ohess.ColSize); // HDebug.Assert(hess.RowSize == ohess.RowSize); // HDebug.Assert(vhess.Size == vohess.Size); // for(int c=0; c<vhess.ColSize; c++) // for(int r=0; r<vhess.RowSize; r++) // { // double v = vhess[c,r]; // double vo = vohess[c,r]; // double diff = Math.Abs(v - vo); // if(diff >= tolerance) // { // HDebug.Assert(false); // return false; // } // } //} return(true); }
float GetAngle(Vector3 from, Vector3 to) { float angle = HMath.angle(from.x, from.z, to.x, to.z); if (angle < 0) { angle += 360; } return(angle); }
/// <inheritdoc /> public void Draw(Window window, Camera camera) { ScreenPoint pos = camera.WorldToViewportPosition(Position.PixelTranslate(Rect.BottomLeft)); int w = HMath.RoundToInt(Rect.Extents.X * 2); int h = HMath.RoundToInt(Rect.Extents.Y * 2); ScreenRect rect = new ScreenRect(pos.X, pos.Y, w, h); window.DrawRect(rect, Fill, Color); }
/// <summary> /// Формирование запроса /// </summary> protected override void setQuery() { int idReq = HMath.GetRandomNumber() ,i = -1; string cmd = string.Empty; //Формировать запрос i = 0; foreach (GroupSignalsKTSTUsql.SIGNALIdsql s in m_arSignals) { if (s.IsFormula == false) { if (i == 0) { cmd = @"List"; } else if (i == 1) { cmd = @"ListAdd"; } else { ; // оставить без изменений } m_strQuery += @"exec e6work.dbo.ep_AskVTIdata @cmd='" + cmd + @"'," + @"@idVTI=" + s.m_iIdLocal + @"," + @"@TimeStart='" + DateTimeBeginFormat + @"'," + @"@TimeEnd='" + DateTimeEndFormat + @"'," + @"@idReq=" + idReq + @";"; i++; } else { // формула ; } } m_strQuery += @"SELECT idVTI as [ID],idReq,TimeIdx,TimeRTC,TimeSQL as [DATETIME],idState,ValueFl as [VALUE],ValueInt,IsInteger,idUnit" + @", DATEDIFF(HH, GETDATE(), GETUTCDATE()) as [UTC_OFFSET]" + @" FROM e6work.dbo.VTIdataList" + @" WHERE idReq=" + idReq + @";"; m_strQuery += @"exec e6work.dbo.ep_AskVTIdata @cmd='" + @"Clear" + @"'," + @"@idReq=" + idReq + @";"; }
/// <summary> /// Linearly interpolates between two <see cref="WorldCoordinate"/>s. /// </summary> /// <param name="a">The interpolation start point.</param> /// <param name="b">The interpolation end point.</param> /// <param name="t">A 0-1 fraction, indicating which value between the two points to return.</param> /// <returns>A <see cref="WorldCoordinate"/> value between the start and end point.</returns> public static WorldCoordinate Lerp(WorldCoordinate a, WorldCoordinate b, float t) { WorldCoordinate diff = b - a; float secAdd = diff.Sector * t; float subAdd = diff.Subposition * t; float secRem = secAdd % 1; int sec = a.Sector + HMath.FloorToInt(secAdd); float sub = a.Subposition + subAdd + secRem; return(new WorldCoordinate(sec, sub, false)); }
public static double[,] ModeContribToBFactorCorr(IList <Mode> modes1, IList <Mode> modes2) { /// Similar to "double[] ModeContribToBFactorCorr(bfactor1, modes2)", /// the correlation between bfactor1 and bfactor 2 can be decomposed as /// the list of correlation contributions by "normalized bfactor by modes1.m_i" /// and "normalized bfactor by modes2.m_j" /// in a matrix form. /// /// therefore, the correlation of bfactor1 and bfactor(modes2) is determined as their normalized dot-product: /// corr = dot(nbfactor1, nbfactor2) / (n-1) /// = 1/(n-1) * dot(nbfactor1, nmwbfactor(modes2.m1) + nmwbfactor(modes2.m2) + ... ) /// = 1/(n-1) * ( dot(nbfactor1, nmwbfactor(modes2.m1)) + dot(nbfactor1, nmwbfactor(modes2.m2)) + ... ) /// = 1/(n-1) * ( dot(nmwbfactor(modes1.m1), nmwbfactor(modes2.m1)) + dot(nmwbfactor(modes1.m1), nmwbfactor(modes2.m2)) + ... /// dot(nmwbfactor(modes1.m2), nmwbfactor(modes2.m1)) + dot(nmwbfactor(modes1.m2), nmwbfactor(modes2.m2)) + ... ) /// = 1/(n-1) * sum_{ i1=1..m1, i2=1..m2 } dot(nmwbfactor(modes1.m_i), nmwbfactor(modes2.m_j)) /// = sum_{ i1=1..m1, i2=1..m2 } dot(nmwbfactor(modes1.m_i), nmwbfactor(modes2.m_j))/(n-1) /// = sum_{ i1=1..m1, i2=1..m2 } "correlation contribution by modes1.m_i and modes2.m_j" /// Vector[] nbfactor1mw = GetBFactorModewiseNormalized(modes1); Vector[] nbfactor2mw = GetBFactorModewiseNormalized(modes2); int n = nbfactor1mw[0].Size; int m1 = modes1.Count; HDebug.Assert(nbfactor1mw.Length == m1); int m2 = modes2.Count; HDebug.Assert(nbfactor2mw.Length == m2); MatrixByArr contrib = new double[m1, m2]; for (int i1 = 0; i1 < m1; i1++) { for (int i2 = 0; i2 < m2; i2++) { HDebug.Assert(nbfactor1mw[i1].Size == n); HDebug.Assert(nbfactor2mw[i2].Size == n); contrib[i1, i2] = LinAlg.VtV(nbfactor1mw[i1], nbfactor2mw[i2]) / (n - 1); } } if (HDebug.IsDebuggerAttached) { Vector bfactor1 = modes1.GetBFactor().ToArray(); Vector nbfactor1 = GetBFactorNormalized(bfactor1); Vector bfactor2 = modes2.GetBFactor().ToArray(); Vector nbfactor2 = GetBFactorNormalized(bfactor2); double corr0 = HMath.HCorr(bfactor1, bfactor2); double corr1 = LinAlg.VtV(nbfactor1, nbfactor2) / (n - 1); double corr2 = contrib.ToArray().HSum(); HDebug.AssertTolerance(0.00000001, corr0 - corr1, corr0 - corr2, corr1 - corr2); } return(contrib); }
public static double[] ModeContribToBFactorCorr(Vector bfactor1, IList <Mode> modes2) { /// the correlation(corr) of two bfactors (bfactor1, bfactor 2) is the same to /// the dot product of their normalizeds (mean 0, variance 1): /// corr = Math.HCorr( bfactor1, bfactor2) /// = Math.HCorr(nbfactor1, nbfactor2) /// = LinAlg.VtV(nbfactor1, nbfactor2) (for biased estimation) /// = LinAlg.VtV(nbfactor1, nbfactor2) / (n-1) (for unbiased estimation) /// /// bfactor of mode(m1,m2,...) can be determined by the sum of bfactors of each mode: /// bfactor(mode) = bfactor(m1) + bfactor(m2) + ... /// /// in the similar manner, the normalized bfactor of mode(m1,m2,...) is determined by /// sum of normalized-modewise-bfactor (GetBFactorModewiseNormalized): /// normal-bfactor(mode) = nmwbfactor(m1) + nmwbfactor(m2) + ... /// /// therefore, the correlation of bfactor1 and bfactor(modes2) is determined as their normalized dot-product: /// corr = dot(nbfactor1, nbfactor2) / (n-1) /// = dot(nbfactor1, nmwbfactor(modes2.m1) + nmwbfactor(modes2.m2) + ... ) / (n-1) /// = dot(nbfactor1, nmwbfactor(modes2.m1))/(n-1) + dot(nbfactor1, nmwbfactor(modes2.m2)) / (n-1) + ... /// Vector nbfactor1 = GetBFactorNormalized(bfactor1); Vector[] nbfactor2mw = GetBFactorModewiseNormalized(modes2); int n = bfactor1.Size; int m = modes2.Count; HDebug.Assert(nbfactor2mw.Length == m); Vector contrib = new double[m]; for (int i = 0; i < m; i++) { contrib[i] = LinAlg.VtV(nbfactor1, nbfactor2mw[i]) / (n - 1); } if (HDebug.IsDebuggerAttached) { Vector bfactor2 = modes2.GetBFactor().ToArray(); Vector nbfactor2 = GetBFactorNormalized(bfactor2); double corr0 = HMath.HCorr(bfactor1, bfactor2); double corr1 = LinAlg.VtV(nbfactor1, nbfactor2) / (n - 1); double corr2 = contrib.Sum(); HDebug.AssertTolerance(0.00000001, corr0 - corr1, corr0 - corr2, corr1 - corr2); } return(contrib); }
/// <summary> /// Constructs a new WorldCoordinate at the given position. /// <para>If clampSubposition is false, subposition values not within 0-1 will be added to the /// new <see cref="WorldCoordinate"/>'s sector position.</para> /// For instance, setting the sector to 1 and subposition 1.5 would place the new <see cref="WorldCoordinate"/> /// at sector 2, subposition 0.5. /// </summary> /// <param name="sector">The new <see cref="WorldCoordinate"/>'s sector position.</param> /// <param name="subposition">The new <see cref="WorldCoordinate"/>'s subposition within its sector.</param> /// <param name="clampSubposition">Whether to clamp subposition between 0 and 1, or add excess /// position to the sector value.</param> public WorldCoordinate(int sector, float subposition, bool clampSubposition = true) { if (clampSubposition) { Sector = sector; Subposition = HMath.Clamp(subposition, 0, 1 - float.Epsilon); } else { int diff = HMath.FloorToInt(subposition); Sector = sector + diff; Subposition = subposition - diff; } }
/// <summary> /// Установить содержание для запроса /// </summary> protected override void setQuery() { int idReq = HMath.GetRandomNumber() , i = -1; string cmd = string.Empty; //Формировать запрос i = 0; foreach (GroupSignalsKTSTUDsql.SIGNALIdsql s in m_arSignals) { if (s.IsFormula == false) { m_strQuery += string.Format(@"exec dbo.ep_AskVTIdata @cmd='{0}'" + @", @idVTI={1}" + @", @TimeStart='{2}'" + @", @TimeEnd='{3}'" + @", @idReq={4};" , i++ == 0 ? @"List" : @"ListAdd", s.m_iIdLocal, DateTimeBeginFormat, DateTimeEndFormat, idReq); } else { // формула ; } } // все поля idVTI, idReq, TimeIdx, TimeRTC, TimeSQL, idState, ValueFl, ValueInt, IsInteger, idUnit m_strQuery += string.Format(@"SELECT res.[idVTI] as [ID], SUM(res.[ValueFl]) as [VALUE]" + @", res.[DATETIME]" //+ @", {2} as [UTC_OFFSET]" //DATEDIFF(HOUR, GETDATE(), GETUTCDATE()) as [UTC_OFFSET] + @", COUNT(*) as [COUNT]" + @" FROM (" + @"SELECT [idVTI], [ValueFl]" + @", DATEADD(MINUTE, ceiling(DATEDIFF(MINUTE, DATEADD(DAY, DATEDIFF(DAY, 0, CAST('{0}' as datetime)), 0), [TimeSQL]) / 60.) * 60, DATEADD(DAY, DATEDIFF(DAY, 0, CAST('{0}' as datetime)), 0)) as [DATETIME]" + @" FROM [VTIdataList]" + @" WHERE idREQ = {1}" + @" GROUP BY [IdResult], [idVTI], [ValueFl]" + @", DATEADD(MINUTE, ceiling(DATEDIFF(MINUTE, DATEADD(DAY, DATEDIFF(DAY, 0, CAST('{0}' as datetime)), 0), [TimeSQL]) / 60.) * 60, DATEADD(DAY, DATEDIFF(DAY, 0, CAST('{0}' as datetime)), 0))" + @") res" + @" GROUP BY [idVTI], [DATETIME]" + @" ORDER BY [idVTI], [DATETIME];" , DateTimeBeginFormat, idReq); //, TimeSpan.FromSeconds(m_secOffsetUTCToData).Hours m_strQuery += string.Format(@"exec [dbo].ep_AskVTIdata @cmd='{0}'" + @", @idReq={1};", @"Clear", idReq); }
public static Trans3 GetTrans(IList <Vector> C1, IList <Vector> C2, HPack <int> optIter = null, HPack <List <double> > optListWeightSum = null) { HDebug.Assert(C1.Count == C2.Count); int size = C1.Count; if (optIter != null) { optIter.value = 0; } Trans3 trans0 = new Trans3(new double[3], 1, Quaternion.UnitRotation); Trans3 trans1 = Geometry.AlignPointPoint.MinRMSD.GetTrans(C2, C1); if (optListWeightSum != null) { optListWeightSum.value = new List <double>(); } while ((trans0.TransformMatrix - trans1.TransformMatrix).ToArray().HAbs().HMax() > 0.00000001) { if (optIter != null) { optIter.value++; } Vector[] C2trans = trans1.GetTransformed(C2).ToArray(); double[] weight = new double[size]; double[] dist2s = new double[size]; for (int i = 0; i < size; i++) { double dist2 = (C1[i] - C2trans[i]).Dist2; dist2 = HMath.Between(0.001, dist2, double.PositiveInfinity); weight[i] = 1 / dist2; dist2s[i] = dist2; } if (optListWeightSum != null) { optListWeightSum.value.Add(weight.Sum()); } trans0 = trans1; trans1 = Geometry.AlignPointPoint.MinRMSD.GetTrans(C2, C1, weight); } return(trans1); }
static void Main(string[] args) { Console.WriteLine("any key start"); Console.ReadKey(); var AO1 = CompilerHelper.ASyncBuild_MHX_DATA(new[] { "demo.exe" }); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); int index = 0; while (AO1.isDone == false) { //Console.SetCursorPosition(index, 2); Console.Write("."); index++; index = HMath.Clamp(index, 0, 100); //Console.SetCursorPosition(0, 3); Console.WriteLine(AO1.Log); Thread.Sleep(500); } Console.WriteLine(); Console.WriteLine("FINISHED 1"); var AO2 = Compiler.AsyncTryComplire("输出.exe"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); index = 0; while (AO2.isDone == false) { Console.Write("."); index++; index = HMath.Clamp(index, 0, 100); Console.WriteLine(AO1.Log); Thread.Sleep(500); } Console.WriteLine(); Console.WriteLine("ALL FINISHED.."); Console.WriteLine("Any key esc."); Console.ReadKey(); }
/// <summary> /// Проверка на изменение значений в двух таблицах /// </summary> /// <param name="origin">оригинальная таблица</param> /// <param name="editValue">значение</param> /// <param name="i">номер строки</param> /// <param name="idAlg">номер алгоритма</param> /// <param name="typeValues">тип данных</param> /// <returns>показатель изменения</returns> private int diffRowsInTables(DataTable origin, double editValue, int i, string formatRound, HandlerDbTaskCalculate.ID_VIEW_VALUES typeValues) { int quality = 1; double originValues; //??? зачем сортировка origin = sortDataTable(origin, "ID_PUT, WR_DATETIME"); if (origin.Rows.Count - 1 < i) { originValues = 0; } else { originValues = //HPanelTepCommon.AsParseToF( HMath.doubleParse( origin.Rows[i]["VALUE"].ToString() ); } switch (typeValues) { case HandlerDbTaskCalculate.ID_VIEW_VALUES.ARCHIVE: //??? почему сравниваются строки if (originValues.ToString(formatRound, CultureInfo.InvariantCulture).Equals(editValue.ToString().Trim()) == false) { quality = 2; } break; case HandlerDbTaskCalculate.ID_VIEW_VALUES.SOURCE_LOAD: quality = 1; break; case HandlerDbTaskCalculate.ID_VIEW_VALUES.DEFAULT: break; default: break; } return(quality); }
override public void Play() { isPlay = true; from = fromTransform.position; to = toTransform.position; localTo = to - from; content.position = from; time = localTo.magnitude / speed; backtime = time / 4; arrowScale = localTo.magnitude / 2; arrow.eulerAngles = new Vector3(0F, 0F, HMath.angle(0, 0, localTo.x, localTo.y)); arrow.localScale = new Vector3(0, Mathf.Clamp(0, 0, 2F), 1); _time = 0; StopAllCoroutines(); StartCoroutine(Playing()); }
public static void DrawCircle(Vector3 position, float radius) { //Gizmos int smoothAngle = 10; int count = 360 / smoothAngle; Vector3 prePoint = HMath.PointAngle(position, 0, radius); Vector3 point; for (int i = 1; i < count - 1; i++) { int angle = smoothAngle * i; point = HMath.PointAngle(position, angle, radius); Gizmos.DrawLine(prePoint, point); prePoint = point; } point = HMath.PointAngle(position, 360, radius); Gizmos.DrawLine(prePoint, point); }
public List <Vector3> GetPoints(int num) { List <Vector3> list = new List <Vector3>(); float gap = (angleEnd - angleBegin) / num; int mi = mGetPointIndex % 4; int sg = mi % 2 == 0 ? 1 : -1; float offset = sg * gap / (1 + mi) + gap * 0.5f; // Debug.Log("offset=" + offset + " mGetPointIndex=" + mGetPointIndex + " count=" + count + " gap=" + gap); for (int i = 0; i < num; i++) { float a = angleBegin + gap * i + offset; Vector3 p = HMath.PointAngle(o, a, r + mGetPointIndex * 0f); list.Add(p); } mGetPointIndex++; count += num; return(list); }
public Attack getNearestAttack(Entity thisEntity, Point tPoint) { Attack nAttack = Attacks[0]; double dist = HMath.Distance(tPoint, thisEntity.Bounds.Center); foreach (Attack a in Attacks) { if (a.Owner == thisEntity) { continue; } double d = HMath.Distance(tPoint, a.Rectangle.Center); if (d < dist) { dist = d; nAttack = a; } } return(nAttack); }
public NearEntity getNearestEntity(Entity thisEntity, Point tPoint) { Entity nEntity = GScreen.Player; double dist = HMath.Distance(tPoint, nEntity.Bounds.Center); foreach (Entity e in Entities) { if (!e.Alive || e == thisEntity) { continue; } double d = HMath.Distance(tPoint, e.Bounds.Center); if (d < dist) { dist = d; nEntity = e; } } return(new NearEntity(nEntity, dist)); }
public void MoveTo(UnitCtl fromCtl, UnitCtl toCtl) { fromUnitData = fromCtl.unitData; toUnitData = toCtl.unitData; this.from = fromCtl.transform; this.to = toCtl.transform; navMeshAgent.SetDestination(to.position); Vector3 fromPoint = from.position; Vector3 toPoint = to.position; Vector3 direction = (toPoint - fromPoint).normalized * beginDistance; float radian = HMath.radian(0, 0, direction.x, direction.z); radian += Mathf.PI * 0.5F; direction += fromPoint; float x = HMath.radianPointX(radian, gap * index, direction.x); float z = HMath.radianPointY(radian, gap * index, direction.z); begionTarget.x = x; begionTarget.z = z; direction = (toPoint - fromPoint).normalized * endDistance; radian = HMath.radian(0, 0, direction.x, direction.z); radian += Mathf.PI * 0.5F; direction = toPoint - direction; x = HMath.radianPointX(radian, gap * index, direction.x); z = HMath.radianPointY(radian, gap * index, direction.z); endTarget.x = x; endTarget.z = z; Out(); }