mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:02:44 +00:00 
			
		
		
		
	 2331fe5e68
			
		
	
	
		2331fe5e68
		
	
	
	
	
		
			
			Interpolation is needed in more than one place, and I couldn't find a central place where I could borrow a readily available interpolation routine, so I've implemented the first simple interpolation object. More will follow for more complex scenarios.
		
			
				
	
	
		
			27 lines
		
	
	
	
		
			478 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
	
		
			478 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Rodrigo Tobar <rtobarc@gmail.com>.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Span.h>
 | |
| #include <AK/Vector.h>
 | |
| 
 | |
| namespace PDF {
 | |
| 
 | |
| class LinearInterpolation1D {
 | |
| 
 | |
| public:
 | |
|     LinearInterpolation1D(float x_min, float x_max, float y_min, float y_max);
 | |
|     float interpolate(float) const;
 | |
|     void interpolate(Span<float> const& x, Span<float> y) const;
 | |
| 
 | |
| private:
 | |
|     float m_x_min;
 | |
|     float m_y_min;
 | |
|     float m_slope;
 | |
| };
 | |
| 
 | |
| }
 |