one.empty3.feature.pio.DiffE3 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of empty3-library-3d Show documentation
Show all versions of empty3-library-3d Show documentation
3D rendering engine. Plus modelling. Expected glsl textures 3d and 2d rendering3D primitives, and a lot of scenes' samples to test.+ Game Jogl reworked, Calculator (numbers and vectors). Java code parser implementation starts (<=1.2)
The newest version!
/*
*
* * Copyright (c) 2024. Manuel Daniel Dahmen
* *
* *
* * Copyright 2024 Manuel Daniel Dahmen
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/
/*
comparaipar cerlcle d intensite et
de lumierrs filtrers.
*/
package one.empty3.feature.pio;
import one.empty3.feature.PixM;
import one.empty3.io.ProcessFile;
import one.empty3.library.*;
import one.empty3.library.shader.Vec;
import java.awt.Color;
import java.io.File;
import java.awt.Point;
import java.util.*;
import javax.imageio.ImageIO;
class Circle {
double x, y, r, a;
public PixM m;
Color c;
double i;
public Circle(PixM m, double x, double a,
double y, double r) {
this.x = x;
this.y = y;
this.r = r;
this.a = a;
this.m = m;
}
public void rotate(double angle) {
a += angle;
}
public double get(double r, double g, double b) {
return Math.sqrt(r * r + g * g + b * b);
}
public Point3D get(double a, double r) {
Point3D n = new Point3D(r * Math.cos(2 * Math.PI * a),
r * Math.sin(2 * Math.PI * a), 0.0);
return n;
}
public void variate(double x, double y,
double r, double rotate) {
this.x += x;
this.y += y;
this.r += r;
this.a += rotate;
}
public double getIntensity(int i, int j) {
double count = 0.0;
double
i0, j0;
double iin = 0.0;
double tin = 0.0;
for (i0 = i - r; i0 < i + r; i0++) {
for (j0 = i - r; j0 < i + r; j0++) {
if (Math.sqrt((i0 - i) * (i0 - i)
+ (j0 - j) * (j0 - j))
<= r) {
count++;
iin = m.getIntensity((int) i0, (int) j0);
tin += iin;
}
}
}
return tin / count;
}
public Circle getLevel() {
Circle c = this;
// I mean. Parcourir le cercle
// mesurer I / numPoints
// for(int i=Math.sqrt()
// return c;
int count = 0;
double intensity = 0.0;
c.r = r;
for (double i = c.x - c.r; i <= c.x + c.r; i++) {
for (double j = c.y - c.r; j <= c.y + c.r; j++) {
if (Math.sqrt((i - c.x) * (i - c.x) + (j - c.y) * (j - c.y)) <= c.r * c.r
&& c.x - c.r >= 0 && c.y - c.r >= 0 && c.x + c.r < c.m.getColumns() && c.y + c.r < c.m.
getLines()) {
intensity += c.m.getIntensity((int) i, (int) j);
count++;
}
}
}
if (count > 0) {
c.i = intensity / count;
} else {
c.i = 0.0;
c.r = 0.0;
}
return c;
}
public double match(Circle b) {
return getLevel().getIntensity((int) x, (int) y) - b.getLevel().getIntensity((int) b.x, (int) b.y);
}
/*
public double dist(Circle b) {
double diff = 0.0;
for(int i = (int)(-b.x+ b.r); i