1 /* 2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> 3 * (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com> 4 * 5 * This file is part of lsp-plugins 6 * Created on: 27 нояб. 2015 г. 7 * 8 * lsp-plugins is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * any later version. 12 * 13 * lsp-plugins is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef GRAPHICS_H_ 23 #define GRAPHICS_H_ 24 25 26 namespace lsp 27 { 28 bool line2d_equation 29 ( 30 float x1, float y1, 31 float x2, float y2, 32 float &a, float &b, float &c 33 ); 34 35 bool line2d_equation 36 ( 37 float dx, float dy, 38 float &a, float &b, float &c 39 ); 40 41 bool line2d_intersection 42 ( 43 float a1, float b1, float c1, 44 float a2, float b2, float c2, 45 float &x, float &y 46 ); 47 48 float distance2d(float x1, float y1, float x2, float y2); 49 50 float scalar_product2d(float x1, float y1, float x2, float y2); 51 52 float vector_product2d(float x1, float y1, float x2, float y2); 53 54 float get_angle_2d 55 ( 56 float x0, float y0, // Coordinates of center 57 float x, float y // Coordinates of dot 58 ); 59 60 bool clip_line2d( 61 float dx, float dy, // Line equation 62 float lc, float rc, float tc, float bc, // Corners from left, right, top, bottom 63 float &cx1, float &cy1, float &cx2, float &cy2 // Results 64 ); 65 66 bool clip_line2d( 67 float a, float b, float c, // Line equation 68 float lc, float rc, float tc, float bc, // Corners from left, right, top, bottom 69 float &cx1, float &cy1, float &cx2, float &cy2 // Results 70 ); 71 72 bool clip_line2d( 73 float x1, float x2, float y1, float y2, // Coordinates of two points 74 float lc, float rc, float tc, float bc, // Corners from left, right, top, bottom 75 float &cx1, float &cy1, float &cx2, float &cy2 // Results 76 ); 77 78 void locate_line2d( 79 float a, float b, float c, // Line equation 80 float px, float py, // Point of the line 81 float &ma, float &mb, float &mc // New equation 82 ); 83 84 bool locate_line2d( 85 float dx, float dy, // Line equation 86 float px, float py, // Point of the line 87 float &ma, float &mb, float &mc // New equation 88 ); 89 90 bool clip2d( 91 float x, float y, // Coordinates of point 92 float lc, float rc, float tc, float bc // Corners: left, right, top, bottom 93 ); 94 95 } 96 97 98 #endif /* GRAPHICS_H_ */ 99