more fixes
This commit is contained in:
parent
2d5d2fda4b
commit
8da067fec2
@ -18,7 +18,7 @@ mod relation;
|
||||
|
||||
fn main() {
|
||||
use entity::{Point, PointRef, Var};
|
||||
use math::{Point2, eqn, Region2};
|
||||
use math::{Point2, eqn, Region2, Rot2};
|
||||
use relation::{Relation, ResolveResult};
|
||||
|
||||
env_logger::init();
|
||||
@ -48,8 +48,9 @@ fn main() {
|
||||
let c4 = relation::PointAngle::new_vertical(p1.clone(), p2.clone());
|
||||
let c3 = relation::PointAngle::new_horizontal(p2.clone(), p3.clone());
|
||||
let c2 = relation::AlignedDistance::new_vertical(p1.clone(), p2.clone(), 12.);
|
||||
let c5 = relation::PointAngle::new(p1.clone(), p3.clone(), Rot2::from_angle_deg(45.));
|
||||
let mut relations: Vec<Box<dyn Relation>> =
|
||||
vec![/*Box::new(c1),*/ Box::new(c2), Box::new(c3), Box::new(c4)];
|
||||
vec![/*Box::new(c1),*/ Box::new(c2), Box::new(c3), Box::new(c4), Box::new(c5)];
|
||||
let mut constrained: Vec<Box<dyn Relation>> = Vec::new();
|
||||
let mut any_underconstrained = true;
|
||||
let mut any_constrained = true;
|
||||
|
@ -199,6 +199,9 @@ fn distribute_product_sums(mut es: Exprs) -> Expr {
|
||||
trace!("distribute_product_sums: {}", Product(es.clone()));
|
||||
use itertools::Itertools;
|
||||
use Expr::*;
|
||||
for e in &mut es {
|
||||
*e = e.clone().distribute();
|
||||
}
|
||||
let sums = es
|
||||
.drain_filter(|e| match e {
|
||||
Sum(_) => true,
|
||||
@ -383,6 +386,10 @@ impl Expr {
|
||||
match v {
|
||||
box Const(c) => Const(-c),
|
||||
box Neg(v) => *v,
|
||||
box Product(mut es) => {
|
||||
es.push(Const(-1.));
|
||||
Product(es)
|
||||
}
|
||||
e => Product(vec![Const(-1.), *e]),
|
||||
}
|
||||
}
|
||||
|
@ -212,6 +212,7 @@ impl Line2 {
|
||||
+ b_0.y.clone() * a_c.clone())
|
||||
/ (a_s.clone() * b_c.clone() - a_c.clone() * b_s.clone());
|
||||
// Region2::Singleton(b.evaluate(t_b))
|
||||
trace!("intersect a: {}, b: {}, t_b = {}", a, b, t_b);
|
||||
let res = Region2::Line(b.clone().with_extent(Region1::Singleton(t_b.simplify())));
|
||||
trace!("intersect a: {}, b: {} = {}", a, b, res);
|
||||
res
|
||||
|
@ -92,8 +92,8 @@ impl<T> Point2<T> {
|
||||
impl Point2<Value> {
|
||||
pub fn simplify(self) -> Self {
|
||||
Self {
|
||||
x: self.x.simplify(),
|
||||
y: self.y.simplify(),
|
||||
x: self.x.distribute().simplify().distribute().simplify(),
|
||||
y: self.y.distribute().simplify().distribute().simplify(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -170,6 +170,10 @@ impl Rot2 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_angle_deg(angle_deg: Scalar) -> Self {
|
||||
Self::from_angle(angle_deg * std::f64::consts::PI / 180.)
|
||||
}
|
||||
|
||||
pub fn cardinal(index: i64) -> Self {
|
||||
match index % 4 {
|
||||
0 => Rot2 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user