protected float GetDistance(Transform screenTransform, NormalizedLandmark a, NormalizedLandmark b) { var aPos = GetPosition(screenTransform, a, false, false); var bPos = GetPosition(screenTransform, b, false, false); return(Vector3.Distance(aPos, bPos)); }
/// <summary> /// Renders a line on a screen. /// It is assumed that the screen is vertical to terrain and not inverted. /// </summary> /// <param name="isFlipped"> /// if true, x axis is oriented from right to left (top-right point is (0, 0) and bottom-left is (1, 1)) /// </param> /// <remarks> /// In <paramref name="point" />, y-axis is oriented from top to bottom. /// </remarks> public void Draw(Transform screenTransform, NormalizedLandmark a, NormalizedLandmark b, bool isFlipped = false, bool isFiltered = false) { var src = GetPositionFromNormalizedPoint(screenTransform, a.X, a.Y, isFlipped, isFiltered); var dst = GetPositionFromNormalizedPoint(screenTransform, b.X, b.Y, isFlipped, isFiltered); Draw(screenTransform, src, dst); }
/// <summary> /// Renders a sphere on a screen. /// It is assumed that the screen is vertical to terrain and not inverted. /// </summary> /// <param name="isFlipped"> /// if true, x axis is oriented from right to left (top-right point is (0, 0) and bottom-left is (1, 1)) /// </param> /// <remarks> /// In <paramref name="point" />, y-axis is oriented from top to bottom. /// </remarks> public void Draw(Transform screenTransform, NormalizedLandmark point, bool isFlipped = false, float scale = 0.5f) { gameObject.transform.position = GetPosition(screenTransform, point, isFlipped); gameObject.transform.localScale = scale * Vector3.one; GameObject parent = GameObject.Find("2DAnnotations"); if (parent) { gameObject.transform.parent = parent.transform; } }
/// <summary> /// Renders a circle on a screen. /// It is assumed that the screen is vertical to terrain and not inverted. /// </summary> /// <param name="isFlipped"> /// if true, x axis is oriented from right to left (top-right point is (0, 0) and bottom-left is (1, 1)) /// </param> /// <remarks> /// In <paramref name="center" />, y-axis is oriented from top to bottom. /// </remarks> public void Draw(Transform screenTransform, NormalizedLandmark center, float r, bool isFlipped = false, bool isFiltered = false) { var centerPos = GetPosition(screenTransform, center, isFlipped, isFiltered); var startPosRel = new Vector3(r, 0, 0); var positions = new Vector3[PositionSize]; for (var i = 0; i < PositionSize; i++) { var q = Quaternion.Euler(0, 0, i * 360 / PositionSize); positions[i] = q * startPosRel + centerPos; } gameObject.GetComponent <LineRenderer>().SetPositions(positions); }
protected Vector3 GetPosition(Transform screenTransform, NormalizedLandmark point, bool isFlipped, bool isFiltered) { return(GetPositionFromNormalizedPoint(screenTransform, point.X, point.Y, isFlipped, isFiltered)); }
protected Vector3 Get3DPosition(Transform screenTransform, NormalizedLandmark point, bool isFlipped) { int zScale = 20; return(Get3DPositionFromNormalizedPoint(screenTransform, point.X, point.Y, point.Z * zScale, isFlipped)); }
/// <summary> /// Renders a sphere on a screen. /// It is assumed that the screen is vertical to terrain and not inverted. /// </summary> /// <param name="isFlipped"> /// if true, x axis is oriented from right to left (top-right point is (0, 0) and bottom-left is (1, 1)) /// </param> /// <remarks> /// In <paramref name="point" />, y-axis is oriented from top to bottom. /// </remarks> public void Draw(Transform screenTransform, NormalizedLandmark point, bool isFlipped = false, bool isFiltered = false, float scale = 0.5f) { gameObject.transform.position = GetPosition(screenTransform, point, isFlipped, isFiltered); gameObject.transform.localScale = scale * Vector3.one; }