Skip to content

[Feature]: Vector rotation #18

Description

@rchastain2

Hello!

What would you think of adding vector rotation?

I have just made this for myself:

type
  TVector2D_ = record helper for TVector2D
    function Rotate(const Angle: Double): TVector2D;
  end;

function TVector2D_.Rotate(const Angle: Double): TVector2D;
var CosA, SinA, X_, Y_: Double;
begin
  SinCos(Angle, SinA, CosA);
  X_ := X;
  Y_ := Y;
  Result.X := X_ * CosA - Y_ * SinA;
  Result.Y := X_ * SinA + Y_ * CosA;
end;

I attach my full program (using AGGPas).

vector-rotation.zip

Image

(By the way, the beginner guide is a very good idea!)

Proposed API

function TVector2D.Rotate(const Angle: Double): TVector2D;

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions