Here's some C++ code that does what you want:

#include <iostream> struct Vector { float x, y, z; Vector(float x, float y, float z) : x(x), y(y), z(z) { } }; struct Point { float x, y, z; Point(float x, float y, float z) : x(x), y(y), z(z) { } }; std::ostream &operator<<(std::ostream &os, Point p) { return os << '(' << p.x << ',' << p.y << ',' << p.z << ')'; } Vector operator-(Point p1, Point p2) { return Vector(p1.x-p2.x, p1.y-p2.y, p1.z-p2.z); } Point operator+(Point p, Vector v) { return Point(p.x+v.x, p.y+v.y, p.z+v.z); } // --- Start reading here --- Vector rotate_about_y_axis(Vector v, float cos, float sin) { return Vector(v.x * cos - v.z * sin, v.y, v.x * sin + v.z * cos); } Point rotate_about_y_axis_around_center(Point p, float cos, float sin, Point center) { return center + rotate_about_y_axis(p - center, cos, sin); } int main() { Point eye(0.0f, 1.2f, 0.0f); Point lookat(0.0f, 1.0f, -2.0f); float cos = 0.0f; // std::cos(angle) float sin = 1.0f; // std::sin(angle) Point rotated_lookat = rotate_about_y_axis_around_center(lookat, cos, sin, eye); std::cout << "lookat after rotation = " << rotated_lookat << '\n'; }