<commit_before>﻿using OpenTK;
using CjClutter.ObjLoader.Viewer.Extensions;

namespace CjClutter.ObjLoader.Viewer.Camera
{
    public class TrackballCamera : PerspectiveCamera, ITrackballCamera
    {
        private readonly ITrackballCameraRotationCalculator _cameraRotationCalculator;
        
        private Matrix4d _cameraOrientation = Matrix4d.Identity;
        private Matrix4d _tempCameraOrientation = Matrix4d.Identity;

        public TrackballCamera(ITrackballCameraRotationCalculator cameraRotationCalculator)
        {
            _cameraRotationCalculator = cameraRotationCalculator;
        }

        public override Matrix4d GetCameraMatrix()
        {
            var baseMatrix = base.GetCameraMatrix();
            var orientationMatrix = GetOrientationMatrix();

            return orientationMatrix.Multiply(baseMatrix);
        }

        private Matrix4d GetOrientationMatrix()
        {
            //return _cameraOrientation.Multiply(_tempCameraOrientation);
            return _tempCameraOrientation;
        }

        public void Rotate(Vector2d startPoint, Vector2d endPoint)
        {
            var rotation = CalculateRotation(startPoint, endPoint);
            var rotationMatrix = rotation.GetRotationMatrix();
            _tempCameraOrientation = _cameraOrientation.Multiply(rotationMatrix);

            FireCameraChanged();
        }

        public void CommitRotation(Vector2d startPoint, Vector2d endPoint)
        {
            var rotation = CalculateRotation(startPoint, endPoint);
            var rotationMatrix = rotation.GetRotationMatrix();

            _cameraOrientation = _cameraOrientation.Multiply(rotationMatrix);
            _tempCameraOrientation = _cameraOrientation;

            FireCameraChanged();
        }

        private Quaterniond CalculateRotation(Vector2d startPoint, Vector2d endPoint)<commit_msg>TrackballCamera<commit_after>﻿using System;
using OpenTK;
using CjClutter.ObjLoader.Viewer.Extensions;

namespace CjClutter.ObjLoader.Viewer.Camera
{
    public class TrackballCamera : PerspectiveCamera, ITrackballCamera
    {
        private readonly ITrackballCameraRotationCalculator _cameraRotationCalculator;
        
        private Matrix4d _cameraOrientation = Matrix4d.Identity;
        private Matrix4d _tempCameraOrientation = Matrix4d.Identity;

        public TrackballCamera(ITrackballCameraRotationCalculator cameraRotationCalculator)
        {
            _cameraRotationCalculator = cameraRotationCalculator;
        }

        public override Matrix4d GetCameraMatrix()
        {
            var baseMatrix = base.GetCameraMatrix();
            var orientationMatrix = GetOrientationMatrix();

            return orientationMatrix.Multiply(baseMatrix);
        }

        private Matrix4d GetOrientationMatrix()
        {
            return _cameraOrientation.Multiply(_tempCameraOrientation);
        }

        public void Rotate(Vector2d startPoint, Vector2d endPoint)
        {
            var rotation = CalculateRotation(startPoint, endPoint);
            _tempCameraOrientation = rotation.GetRotationMatrix();

            FireCameraChanged();
        }

        public void CommitRotation(Vector2d startPoint, Vector2d endPoint)
        {
            var rotation = CalculateRotation(startPoint, endPoint);
            var rotationMatrix = rotation.GetRotationMatrix();

            _cameraOrientation = _cameraOrientation.Multiply(rotationMatrix);
            _tempCameraOrientation = Matrix4d.Identity;

            FireCameraChanged();
        }

        private Quaterniond CalculateRotation(Vector2d startPoint, Vector2d endPoint)
{'fraction_non_alphanumeric': 0.05785123966942149, 'fraction_numerical': 0.006887052341597796, 'mean_word_length': 2.8342133051742344, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7057416', 'n_tokens_mistral': 904, 'n_tokens_neox': 823, 'n_words': 170}