Skip to content

Commit

Permalink
電気力線が点電荷の表面から均一に出るように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
CaseyNelson314 committed Dec 23, 2023
1 parent 91ab25b commit 4ed6f9d
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions app/script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,26 @@ const CreateElectricLineGeometry = (origin_charge, vector, point_charges, length

const line_material = new THREE.LineBasicMaterial({ color: 0x0000ff });
for (const point_charge of point_charges) {
for (var i = 0; i < 100; i++) {
// 球面上に点を打つ
const theta = Math.random() * Math.PI * 2;
const phi = Math.random() * Math.PI * 2;
const x = 5 * Math.sin(theta) * Math.cos(phi);
const y = 5 * Math.sin(theta) * Math.sin(phi);
const z = 5 * Math.cos(theta);

const line = new THREE.Line(
CreateElectricLineGeometry(
point_charge,
new THREE.Vector3(x, y, z),
point_charges,
500
),
line_material
);
scene.add(line);

for (var n_theta = 0; n_theta < 10; n_theta++) {
for (var n_phi = 0; n_phi < 10; n_phi++) {
const theta = (Math.PI * 2) / 10 * n_theta;
const phi = (Math.PI * 2) / 10 * n_phi;
const x = 5 * Math.sin(theta) * Math.cos(phi);
const y = 5 * Math.sin(theta) * Math.sin(phi);
const z = 5 * Math.cos(theta);

const line = new THREE.Line(
CreateElectricLineGeometry(
point_charge,
new THREE.Vector3(x, y, z),
point_charges,
500
),
line_material
);
scene.add(line);
}
}
// for (var x = -5; x <= 5; x++) {
// for (var y = -5; y <= 5; y++) {
Expand Down

0 comments on commit 4ed6f9d

Please sign in to comment.