public static ExpVector rotateDir2d(ExpVector rv, Exp angle) { var cos = Exp.Cos(angle); var sin = Exp.Sin(angle); return(new ExpVector( cos * rv.x - sin * rv.y, sin * rv.x + cos * rv.y, rv.z )); }
public static ExpVector RotateAround(ExpVector point, ExpVector axis, ExpVector origin, Exp angle) { var a = axis.Normalized(); var c = Exp.Cos(angle); var s = Exp.Sin(angle); var u = new ExpVector(c + (1.0 - c) * a.x * a.x, (1.0 - c) * a.y * a.x + s * a.z, (1 - c) * a.z * a.x - s * a.y); var v = new ExpVector((1.0 - c) * a.x * a.y - s * a.z, c + (1.0 - c) * a.y * a.y, (1.0 - c) * a.z * a.y + s * a.x); var n = new ExpVector((1.0 - c) * a.x * a.z + s * a.y, (1.0 - c) * a.y * a.z - s * a.x, c + (1 - c) * a.z * a.z); var p = point - origin; return(p.x * u + p.y * v + p.z * n + origin); }
public override ExpVector TangentAt(Exp t) { var angle = GetAngleExp(); var cos = Exp.Cos(angle * t + Math.PI / 2); var sin = Exp.Sin(angle * t + Math.PI / 2); var rv = p0.exp - c.exp; return(new ExpVector( cos * rv.x - sin * rv.y, sin * rv.x + cos * rv.y, 0.0 )); }
/* * protected override double OnSelect(Vector3 mouse, Camera camera, Matrix4x4 tf) { * float angle = GetAngle() * Mathf.Rad2Deg; * Debug.Log(angle); * var cp = c.pos; * var rv = p0.pos - cp; * int subdiv = (int)Math.Ceiling(angle / 30); * var vz = Vector3.forward; * var rot = Quaternion.AngleAxis(angle / (subdiv - 1), vz); * var prev = Vector3.zero; * double min = -1; * for(int i = 0; i < subdiv; i++) { * var pos = camera.WorldToScreenPoint(tf.MultiplyPoint(rv + cp)); * if(i > 0) { * var dist = GeomUtils.DistancePointSegment2D(mouse, prev, pos); * if(min > 0 && dist > min) continue; * min = dist; * } * prev = pos; * rv = rot * rv; * } * return min; * } */ public override ExpVector PointOn(Exp t) { var angle = GetAngleExp(); var cos = Exp.Cos(angle * t); var sin = Exp.Sin(angle * t); var rv = p0.exp - c.exp; return(c.exp + new ExpVector( cos * rv.x - sin * rv.y, sin * rv.x + cos * rv.y, 0.0 )); }
public override ExpVector TangentAt(Exp t) { var angle = t * 2.0 * Math.PI; return(new ExpVector(-Exp.Sin(angle), Exp.Cos(angle), 0.0)); }
public override ExpVector PointOn(Exp t) { var angle = t * 2.0 * Math.PI; return(c.exp + new ExpVector(Exp.Cos(angle), Exp.Sin(angle), 0.0) * Radius()); }
public override ExpVector PointOn(Exp t) { var angle = t * 2.0 * Math.PI; return(basis.TransformPosition(new ExpVector(Exp.Cos(angle) * Exp.Abs(r0), Exp.Sin(angle) * Exp.Abs(r1), 0.0))); }