Repository: godotengine/godot
File: core/math/transform_2d.h (C/C++)

Code before:

	Vector2 columns[3];

	_FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return columns[0][0] * v.x + columns[1][0] * v.y; }
	_FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return columns[0][1] * v.x + columns[1][1] * v.y; }

	const Vector2 &operator[](int p_idx) const { return columns[p_idx]; }
	Vector2 &operator[](int p_idx) { return columns[p_idx]; }

	void invert();
	Transform2D inverse() const;

	void affine_invert();
	Transform2D affine_inverse() const;

	void set_rotation(const real_t p_rot);
	real_t get_rotation() const;
	real_t get_skew() const;
	void set_skew(const real_t p_angle);
	_FORCE_INLINE_ void set_rotation_and_scale(const real_t p_rot, const Size2 &p_scale);
	_FORCE_INLINE_ void set_rotation_scale_and_skew(const real_t p_rot, const Size2 &p_scale, const real_t p_skew);
	void rotate(const real_t p_angle);

	void scale(const Size2 &p_scale);
	void scale_basis(const Size2 &p_scale);
	void translate_local(const real_t p_tx, const real_t p_ty);
	void translate_local(const Vector2 &p_translation);

	real_t basis_determinant() const;

	Size2 get_scale() const;
	void set_scale(const Size2 &p_scale);

	_FORCE_INLINE_ const Vector2 &get_origin() const { return columns[2]; }
	_FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { columns[2] = p_origin; }

	Transform2D scaled(const Size2 &p_scale) const;
	Transform2D basis_scaled(const Size2 &p_scale) const;
	Transform2D translated_local(const Vector2 &p_offset) const;
	Transform2D rotated(const real_t p_angle) const;

	Transform2D untranslated() const;

	void orthonormalize();
	Transform2D orthonormalized() const;
	bool is_equal_approx(const Transform2D &p_transform) const;

	Transform2D looking_at(const Vector2 &p_target) const;

	bool operator==(const Transform2D &p_transform) const;
	bool operator!=(const Transform2D &p_transform) const;

Review comment (suggestion):
Even though I think the rename can be ok in this context, I believe would also keep translate (and specially translated) as a global version (just offset the origin). There is merit to to having this version too when you want to move the positioning of an object but not its rotation.

In other words, all the code in this PR being ok, but also add back translate/translated() as global.

Code after:

	Vector2 columns[3];

	_FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return columns[0][0] * v.x + columns[1][0] * v.y; }
	_FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return columns[0][1] * v.x + columns[1][1] * v.y; }

	const Vector2 &operator[](int p_idx) const { return columns[p_idx]; }
	Vector2 &operator[](int p_idx) { return columns[p_idx]; }

	void invert();
	Transform2D inverse() const;

	void affine_invert();
	Transform2D affine_inverse() const;

	void set_rotation(const real_t p_rot);
	real_t get_rotation() const;
	real_t get_skew() const;
	void set_skew(const real_t p_angle);
	_FORCE_INLINE_ void set_rotation_and_scale(const real_t p_rot, const Size2 &p_scale);
	_FORCE_INLINE_ void set_rotation_scale_and_skew(const real_t p_rot, const Size2 &p_scale, const real_t p_skew);
	void rotate(const real_t p_angle);

	void scale(const Size2 &p_scale);
	void scale_basis(const Size2 &p_scale);
	void translate_local(const real_t p_tx, const real_t p_ty);
	void translate_local(const Vector2 &p_translation);

	real_t basis_determinant() const;

	Size2 get_scale() const;
	void set_scale(const Size2 &p_scale);

	_FORCE_INLINE_ const Vector2 &get_origin() const { return columns[2]; }
	_FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { columns[2] = p_origin; }

	Transform2D basis_scaled(const Size2 &p_scale) const;
	Transform2D scaled(const Size2 &p_scale) const;
	Transform2D scaled_local(const Size2 &p_scale) const;
	Transform2D translated(const Vector2 &p_offset) const;
	Transform2D translated_local(const Vector2 &p_offset) const;
	Transform2D rotated(const real_t p_angle) const;
	Transform2D rotated_local(const real_t p_angle) const;

	Transform2D untranslated() const;

	void orthonormalize();
	Transform2D orthonormalized() const;
	bool is_equal_approx(const Transform2D &p_transform) const;

	Transform2D looking_at(const Vector2 &p_target) const;