File indexing completed on 2024-05-26 04:34:13
0001 /* 0002 * SPDX-FileCopyrightText: 2009 Lukas Tvrdy <lukast.dev@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef _METABALL_H_ 0008 #define _METABALL_H_ 0009 0010 #include <cmath> 0011 #include <QtGlobal> 0012 0013 class Metaball 0014 { 0015 public: 0016 ~Metaball() {} 0017 Metaball(qreal x, qreal y, qreal radius): 0018 m_x(x), 0019 m_y(y), 0020 m_radius(radius) {} 0021 0022 qreal equation(qreal x, qreal y) { 0023 //return m_radius / sqrt( pow((x - m_x),2) + pow((y - m_y),2) ); 0024 return (m_radius * m_radius) / (pow((x - m_x), 2) + pow((y - m_y), 2)); 0025 } 0026 0027 qreal x() { 0028 return m_x; 0029 } 0030 0031 qreal y() { 0032 return m_y; 0033 } 0034 0035 qreal radius() { 0036 return m_radius; 0037 } 0038 private: 0039 qreal m_x; 0040 qreal m_y; 0041 qreal m_radius; 0042 0043 }; 0044 0045 #endif // _METABALL_H_ 0046