MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / polarCubicTo

Method polarCubicTo

src/main/java/field/graphics/FLine.java:377–401  ·  view source on GitHub ↗

draws a curve that starts by heading in the `theta1` angle for a distance of roughly `r1` then ends up heading to `destination` coming in at angle `theta2` from roughly `r2` away

(float r1, float theta1, float r2, float theta2, Vec2 destination)

Source from the content-addressed store, hash-verified

375 Vec2 a = last().to.toVec2();
376
377 Vec2 d = Vec2.sub(destination, a, new Vec2());
378
379 Vec2 c1 = new Vec2(d).mul(r1 / 3);
380 Vec2 c2 = new Vec2(d).mul(-r2 / 3);
381
382 c1 = new Quat().setAngleAxis(Math.PI * theta1 / 180, new Vec3(0, 0, 1))
383 .transform(c1.toVec3())
384 .toVec2();
385 c2 = new Quat().setAngleAxis(Math.PI * theta2 / 180, new Vec3(0, 0, 1))
386 .transform(c2.toVec3())
387 .toVec2();
388
389 Vec2.add(c1, a, c1);
390 Vec2.add(c2, destination, c2);
391
392 cubicTo(c1, c2, destination);
393 return this;
394 }
395
396 public FLine polarCubicTo3(float r1, float theta1, float r2, float theta2, Vec3 destination) {
397
398 if (nodes.size() == 0)
399 return moveTo(destination);
400
401 Vec3 a = last().to;
402
403 Vec3 d = Vec3.sub(destination, a, new Vec3());
404

Callers

nothing calls this directly

Calls 11

moveToMethod · 0.95
lastMethod · 0.95
subMethod · 0.95
toVec3Method · 0.95
addMethod · 0.95
cubicToMethod · 0.95
setAngleAxisMethod · 0.80
transformMethod · 0.65
sizeMethod · 0.45
toVec2Method · 0.45
mulMethod · 0.45

Tested by

no test coverage detected