mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-30 15:23:01 +00:00
util-math: Add commonly used mathematical functions
This commit is contained in:
parent
61f20a83ad
commit
d78d3024cc
3 changed files with 56 additions and 0 deletions
|
@ -47,6 +47,7 @@ SET(obs-stream-effects_HEADERS
|
|||
"${PROJECT_SOURCE_DIR}/source/gs-mipmapper.h"
|
||||
"${PROJECT_BINARY_DIR}/source/version.h"
|
||||
"${PROJECT_SOURCE_DIR}/source/strings.h"
|
||||
"${PROJECT_SOURCE_DIR}/source/util-math.h"
|
||||
)
|
||||
SET(obs-stream-effects_SOURCES
|
||||
"${PROJECT_SOURCE_DIR}/source/plugin.cpp"
|
||||
|
@ -63,6 +64,7 @@ SET(obs-stream-effects_SOURCES
|
|||
"${PROJECT_SOURCE_DIR}/source/gs-vertex.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/source/gs-mipmapper.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/source/util-math.cpp"
|
||||
)
|
||||
SET(obs-stream-effects_LOCALE
|
||||
"${PROJECT_SOURCE_DIR}/data/locale/en-US.ini"
|
||||
|
|
21
source/util-math.cpp
Normal file
21
source/util-math.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Modern effects for a modern Streamer
|
||||
* Copyright (C) 2017 Michael Fabian Dirks
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "util-math.h"
|
||||
|
33
source/util-math.h
Normal file
33
source/util-math.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Modern effects for a modern Streamer
|
||||
* Copyright (C) 2017 Michael Fabian Dirks
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define PI 3.1415926535897932384626433832795
|
||||
#define PI2 6.283185307179586476925286766559
|
||||
#define PI2_SQROOT 2.506628274631000502415765284811
|
||||
|
||||
inline double_t Gaussian1D(double_t x, double_t o) {
|
||||
double_t c = (x / o);
|
||||
double_t b = exp(-0.5 * c * c);
|
||||
double_t a = (1.0 / (o * PI2_SQROOT));
|
||||
return a * b;
|
||||
}
|
Loading…
Reference in a new issue