BREAKING: More units of measure work and keyword args (#6291)
* More units of measure work Signed-off-by: Nick Cameron <nrc@ncameron.org> * Update CSG output since engine change --------- Signed-off-by: Nick Cameron <nrc@ncameron.org> Co-authored-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -8,11 +8,13 @@ use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
types::{NumericType, PrimitiveType, RuntimeType},
|
||||
ExecState, KclValue, Point2d, Sketch, TagIdentifier,
|
||||
ExecState, KclValue, Sketch, TagIdentifier,
|
||||
},
|
||||
std::{args::TyF64, utils::between, Args},
|
||||
};
|
||||
|
||||
use super::utils::untype_point;
|
||||
|
||||
/// Returns the point at the end of the given segment.
|
||||
pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let tag: TagIdentifier = args.get_unlabeled_kw_arg("tag")?;
|
||||
@ -562,17 +564,17 @@ async fn inner_tangent_to_end(tag: &TagIdentifier, exec_state: &mut ExecState, a
|
||||
})
|
||||
})?;
|
||||
|
||||
let from = Point2d::from(path.get_to());
|
||||
let from = untype_point(path.get_to()).0;
|
||||
|
||||
// Undocumented voodoo from get_tangential_arc_to_info
|
||||
let tangent_info = path.get_tangential_info();
|
||||
let tan_previous_point = tangent_info.tan_previous_point(from.into());
|
||||
let tan_previous_point = tangent_info.tan_previous_point(from);
|
||||
|
||||
// Calculate the end point from the angle and radius.
|
||||
// atan2 outputs radians.
|
||||
let previous_end_tangent = Angle::from_radians(f64::atan2(
|
||||
from.y - tan_previous_point[1],
|
||||
from.x - tan_previous_point[0],
|
||||
from[1] - tan_previous_point[1],
|
||||
from[0] - tan_previous_point[0],
|
||||
));
|
||||
|
||||
Ok(previous_end_tangent.to_degrees())
|
||||
@ -581,7 +583,7 @@ async fn inner_tangent_to_end(tag: &TagIdentifier, exec_state: &mut ExecState, a
|
||||
/// Returns the angle to match the given length for x.
|
||||
pub async fn angle_to_match_length_x(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let (tag, to, sketch) = args.get_tag_to_number_sketch()?;
|
||||
let result = inner_angle_to_match_length_x(&tag, to, sketch, exec_state, args.clone())?;
|
||||
let result = inner_angle_to_match_length_x(&tag, to.n, sketch, exec_state, args.clone())?;
|
||||
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::degrees())))
|
||||
}
|
||||
|
||||
@ -645,7 +647,7 @@ fn inner_angle_to_match_length_x(
|
||||
/// Returns the angle to match the given length for y.
|
||||
pub async fn angle_to_match_length_y(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let (tag, to, sketch) = args.get_tag_to_number_sketch()?;
|
||||
let result = inner_angle_to_match_length_y(&tag, to, sketch, exec_state, args.clone())?;
|
||||
let result = inner_angle_to_match_length_y(&tag, to.n, sketch, exec_state, args.clone())?;
|
||||
Ok(args.make_user_val_from_f64_with_type(TyF64::new(result, NumericType::degrees())))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user