Advertisement
imk0tter

IMK0TTER_VALVE

Apr 5th, 2024 (edited)
725
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.43 KB | None | 0 0
  1. // IMK0TTER_VALVE.h
  2. //
  3. #pragma once
  4. ////////////////////// !IMPORTANT! //////////////////////
  5. ///////////////TODO: DEFINE MOUSE_PI as PI///////////////
  6. ////////////////////// !IMPORTANT! //////////////////////
  7. #define MOUSE_PI 3.14159265358979323846f
  8. ////////////////////// !IMPORTANT! //////////////////////
  9. ///////////////TODO: DEFINE MOUSE_PI as PI///////////////
  10. ////////////////////// !IMPORTANT! //////////////////////
  11.  
  12. namespace IMK0TTER
  13. {
  14.     namespace MOUSE_CODE
  15.     {
  16.         float ABSN(float INPUT);
  17.         float ATANN(float INPUT);
  18.  
  19.         float CLAMP(float rotations_in_n_units, float half_n_unit);
  20.  
  21.         float TRANSDUCE(float input_in_radians, float size_of_circle);
  22.  
  23.         // TRANSDUCTION is for transducing line segements into rotations
  24.         int RAW_MOUSE_INPUT_TO_PIXELS_ACCELERATION(float input_in_radians, float sensitivity, float radius_in_pixels);
  25.         int RAW_MOUSE_INPUT_TO_PIXELS(float input_in_radians, float sensitivity, float radius_in_pixels);
  26.  
  27.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_DEGREES_TO_RADIUS_IN_PIXELS(float resolution_in_pixels, float fov_in_degrees);
  28.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_DEGREES_TO_CIRCUMFERENCE_IN_PIXELS(float resolution_in_pixels, float fov_in_degrees);
  29.  
  30.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_PIXELS_TO_RADIUS_IN_PIXELS(float resolution_in_pixels, float fov_in_pixels);
  31.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_PIXELS_TO_CIRCUMFERENCE_IN_PIXELS(float resolution_in_pixels, float fov_in_pixels);
  32.     }
  33. }
  34.  
  35. // IMK0TTER_VALVE.cpp : Defines the functions for the static library.
  36. //
  37. #include "IMK0TTER_VALVE.h"
  38.  
  39. #include <math.h>
  40.  
  41. namespace IMK0TTER
  42. {
  43.     namespace MOUSE_CODE
  44.     {
  45.         inline float ABSN(float INPUT) { return sqrtf(INPUT * INPUT); }
  46.         inline float ATANN(float INPUT) { return INPUT / ABSN(INPUT); }
  47.  
  48.         inline float CLAMP(float rotations_in_n_units, float half_n_unit) { return fmodf(truncf(rotations_in_n_units / half_n_unit), 2) * -1 * half_n_unit + fmodf(rotations_in_n_units, half_n_unit); }
  49.  
  50.         inline float TRANSDUCE(float input_in_radians, float size_of_circle) { return ATANN(input_in_radians) * acosf(((size_of_circle * size_of_circle * 2) - (CLAMP(input_in_radians, 2 * size_of_circle) * CLAMP(input_in_radians, 2 * size_of_circle))) / (size_of_circle * size_of_circle * 2)); }
  51.  
  52.         int RAW_MOUSE_INPUT_TO_PIXELS_ACCELERATION(float input_in_radians, float sensitivity, float radius_in_pixels) { return int(fmodf(TRANSDUCE(input_in_radians, 1 / sensitivity) * radius_in_pixels, radius_in_pixels * MOUSE_PI * 2)); }
  53.         int RAW_MOUSE_INPUT_TO_PIXELS(float input_in_radians, float sensitivity, float radius_in_pixels) { return int(input_in_radians * sensitivity * radius_in_pixels); }
  54.  
  55.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_DEGREES_TO_RADIUS_IN_PIXELS(float resolution_in_pixels, float fov_in_degrees) { return (resolution_in_pixels / sinf(MOUSE_PI / (360 / fov_in_degrees))) / 2; }
  56.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_DEGREES_TO_CIRCUMFERENCE_IN_PIXELS(float resolution_in_pixels, float fov_in_degrees) { return RESOLUTION_IN_PIXELS_AND_FOV_IN_DEGREES_TO_RADIUS_IN_PIXELS(resolution_in_pixels, fov_in_degrees) * MOUSE_PI * 2; }
  57.  
  58.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_PIXELS_TO_RADIUS_IN_PIXELS(float resolution_in_pixels, float fov_in_pixels) { return 0.0f; }
  59.         float RESOLUTION_IN_PIXELS_AND_FOV_IN_PIXELS_TO_CIRCUMFERENCE_IN_PIXELS(float resolution_in_pixels, float fov_in_pixels) { return RESOLUTION_IN_PIXELS_AND_FOV_IN_PIXELS_TO_RADIUS_IN_PIXELS(resolution_in_pixels, fov_in_pixels) * MOUSE_PI * 2; }
  60.     }
  61. }
  62.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement