SESEBLO

Unity, Clip Studio, etc.

Unity のベジェ曲線について

表題について、検索すると

unitygeek.hatenablog.com

が出てくるのですが、

  • 若干間違ってる? ので修正
  • 二次のものについて追加

したものを作ってみました。SetConstants部分のみ掲載。

 

private void SetConstants2 () {
    this.Ax = this.b0.x - 2 * this.b1.x + this.b2.x;
    this.Bx = 2 * (this.b1.x - this.b0.x);

    this.Ay = this.b0.y - 2 * this.b1.y + this.b2.y;
    this.By = 2 * (this.b1.y - this.b0.y);
  }

  private void SetConstants3 () {
    this.Ax = this.b3.x -3f * (this.b2.x - this.b1.x) - this.b0.x;
    this.Bx = 3f * (this.b2.x - 2 * this.b1.x + this.b0.x);
    this.Cx = 3f * (this.b1.x - this.b0.x);

    this.Ay = this.b3.y -3f * (this.b2.y - this.b1.y) - this.b0.y;
    this.By = 3f * (this.b2.y - 2 * this.b1.y + this.b0.y);
    this.Cy = 3f * (this.b1.y - this.b0.y);
  }