<= 180f; i += 9f){var point1 = up * remainHeightHalf + Quaternion.AngleAxis(i, -right) * forward * radius;var point2 = up * remainHeightHalf + Quaternion.AngleAxis(i, forward) * right * radius;Gizmos.DrawLine(center + lastPoint1.GetValueOrDefault(point1), center + point1);Gizmos.DrawLine(center + lastPoint2.GetValueOrDefault(point2), center + point2);lastPoint1 = point1;lastPoint2 = point2;}lastPoint1 = (Vector3?)null;for (var i = 0f; i <= 360f; i += 9f){var point1 = up * remainHeightHalf + Quaternion.AngleAxis(i, up) * forward * radius;Gizmos.DrawLine(center + lastPoint1.GetValueOrDefault(point1), center + point1);lastPoint1 = point1;}Gizmos.color = cacheColor;Gizmos.matrix = cacheMatrix;}bool BetweenLineAndSphere(Vector3 circleCenter, float circleRadius,Vector3 point1, Vector3 point2,out Vector3 intersection1, out Vector3 intersection2){float t;var dx = point2.x - point1.x;var dy = point2.y - point1.y;var dz = point2.z - point1.z;var a = dx * dx + dy * dy + dz * dz;var b = 2 * (dx * (point1.x - circleCenter.x) + dy * (point1.y - circleCenter.y) + dz * (point1.z - circleCenter.z));var c = (point1.x - circleCenter.x) * (point1.x - circleCenter.x)+ (point1.y - circleCenter.y) * (point1.y - circleCenter.y)+ (point1.z - circleCenter.z) * (point1.z - circleCenter.z) - circleRadius * circleRadius;var determinate = b * b - 4 * a * c;// Two solutions.t = (float)((-b + Mathf.Sqrt(determinate)) / (2 * a));intersection1 = new Vector3(point1.x + t * dx, point1.y + t * dy, point1.z + t * dz);t = (float)((-b - Mathf.Sqrt(determinate)) / (2 * a));intersection2 = new Vector3(point1.x + t * dx, point1.y + t * dy, point1.z + t * dz);if (intersection1.normalized == Vector3.zero && intersection2.normalized == Vector3.zero)return false;elsereturn true;}bool CylinderVSline(Vector3 start, Vector3 dir, Vector3 aVec, Vector3 bVec, float radius, out Vector3 intersectPoint){intersectPoint = Vector3.zero;// Solution : http://www.gamedev.net/community/forums/topic.asp?topic_id=467789var ab = bVec - aVec;var ao = start - aVec;var aoxAb = Vector3.Cross(ao, ab);var vxAb = Vector3.Cross(dir, ab);var ab2 = Vector3.Dot(ab, ab);var a = Vector3.Dot(vxAb, vxAb);var b = 2 * Vector3.Dot(vxAb, aoxAb);var c = Vector3.Dot(aoxAb, aoxAb) - (radius * radius * ab2);var d = b * b - 4 * a * c;if (d < 0) return false;float time = (-b - Mathf.Sqrt(d)) / (2 * a);if (time < 0) return false;intersectPoint = start + dir * time;var projectionPoint = aVec + Vector3.Project(intersectPoint - aVec, ab.normalized);var distance1 = Mathf.Max(Vector3.Distance(projectionPoint, aVec), Vector3.Distance(projectionPoint, bVec));var distance2 = Vector3.Distance(aVec, bVec);if (distance1 >= distance2)return false;return true;}}
View Code
- 胶囊旅馆价格
- 高原康胶囊
- 蜂胶胶囊哪个牌子好,蜂胶软胶囊哪个牌子好、
- 二弧甲吃多久会导致贫血,吃盐酸二弧胶囊
- 罗红霉素药店卖多少钱,罗红霉素缓释胶囊福州哪个药店有卖
- 罗红霉素哪个厂家最好,罗红霉素胶囊哪个厂家效果好
- 硫酸氨糖软骨素胶囊,如何辨别美国进口硫酸氨糖软骨素胶囊
- 莲雾的营养价值及功效与作用塞来昔布胶囊 莲雾的营养价值及功效
- 布洛芬一天最多吃几次缓释胶囊 布洛芬一天最多吃几次
- 小狗可以吃氟康唑胶囊治疗皮屑吗