Rename Point -> Vec2 to distinguish it clearly from any 3d object
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use coremem::{Driver, mat, meas};
|
||||
use coremem::geom::Point;
|
||||
use coremem::geom::Vec2;
|
||||
|
||||
fn main() {
|
||||
coremem::init_logging();
|
||||
@@ -21,11 +21,11 @@ fn main() {
|
||||
driver.add_measurement(meas::MagneticFlux(width / 2, width / 2));
|
||||
driver.add_measurement(meas::MagneticStrength(width / 2, width / 2));
|
||||
|
||||
let center = Point::new((width/2) as _, (width/2) as _);
|
||||
let center = Vec2::new((width/2) as _, (width/2) as _);
|
||||
|
||||
for y in 0..width {
|
||||
for x in 0..width {
|
||||
let d = Point::new(x as _, y as _) - center;
|
||||
let d = Vec2::new(x as _, y as _) - center;
|
||||
if (inner_rad as _..outer_rad as _).contains(&d.mag()) {
|
||||
*driver.state.get_mut(x, y).mat_mut() = mat::Static::conductor(conductivity).into();
|
||||
} else if d.mag() < ferro_rad as _ {
|
||||
@@ -46,9 +46,9 @@ fn main() {
|
||||
let e = drive_current/conductivity;
|
||||
for y in 0..width {
|
||||
for x in 0..width {
|
||||
let d = Point::new(x as _, y as _) - center;
|
||||
let d = Vec2::new(x as _, y as _) - center;
|
||||
if (inner_rad as _..outer_rad as _).contains(&d.mag()) {
|
||||
let tangent = Point::new(-d.y(), d.x()).with_mag(e);
|
||||
let tangent = Vec2::new(-d.y(), d.x()).with_mag(e);
|
||||
driver.state.impulse_ex(x, y, tangent.x());
|
||||
driver.state.impulse_ey(x, y, tangent.y());
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
use coremem::{consts, Driver, Flt, mat, meas};
|
||||
use coremem::coord::Coord;
|
||||
use coremem::geom::{Circle, Point};
|
||||
use coremem::geom::{Circle, Vec2};
|
||||
|
||||
fn main() {
|
||||
coremem::init_logging();
|
||||
@@ -31,7 +31,7 @@ fn main() {
|
||||
));
|
||||
// driver.add_term_renderer();
|
||||
driver.add_measurement(meas::Label(format!("Conductivity: {}, Imax: {:.2e}", conductivity, peak_current)));
|
||||
driver.add_measurement(meas::Current(Circle::new(Point::new(
|
||||
driver.add_measurement(meas::Current(Circle::new(Vec2::new(
|
||||
to_m(half_width), to_m(half_width)),
|
||||
to_m(conductor_outer_rad))));
|
||||
driver.add_measurement(meas::Magnetization(
|
||||
@@ -62,12 +62,12 @@ fn main() {
|
||||
(half_width + (ferro_inner_rad + ferro_outer_rad) / 2, half_width, 0).into()
|
||||
));
|
||||
|
||||
let center = Point::new(half_width as _, half_width as _);
|
||||
let center = Vec2::new(half_width as _, half_width as _);
|
||||
|
||||
for y in 0..width {
|
||||
for x in 0..width {
|
||||
let loc = Coord::new(x, y, 0);
|
||||
let d = Point::new(loc.x().into(), loc.y().into()) - center;
|
||||
let d = Vec2::new(loc.x().into(), loc.y().into()) - center;
|
||||
let r = d.mag();
|
||||
if (conductor_inner_rad as _..conductor_outer_rad as _).contains(&r) {
|
||||
*driver.state.get_mut(loc).mat_mut() = mat::Static::conductor(conductivity).into();
|
||||
@@ -96,7 +96,7 @@ fn main() {
|
||||
for y in half_width-conductor_outer_rad..half_width+conductor_outer_rad {
|
||||
for x in half_width-conductor_outer_rad..half_width+conductor_outer_rad {
|
||||
let loc = Coord::new(x, y, 0);
|
||||
let d = Point::new(loc.x().into(), loc.y().into()) - center;
|
||||
let d = Vec2::new(loc.x().into(), loc.y().into()) - center;
|
||||
if (conductor_inner_rad as _..conductor_outer_rad as _).contains(&d.mag()) {
|
||||
driver.state.impulse_ez(loc, e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user