style: add .clang-format and format the C++ tree with it
One mechanical pass (clang-format 18.1.8, Google base, 120 columns, T& x, includes untouched). Nothing but whitespace and line breaks moves; tools/check_format.sh lists what would change and CI runs it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,15 +34,19 @@ void bind_core(py::module_& m) {
|
||||
.def("__iter__", [](const PyVec3& p) { return py::iter(py::make_tuple(p.v.x, p.v.y, p.v.z)); })
|
||||
.def("dot", [](const PyVec3& p, const scad::Vec3& o) { return p.v.dot(o); })
|
||||
.def("norm", [](const PyVec3& p) { return p.v.norm(); })
|
||||
.def("normalized", [](const PyVec3& p) {
|
||||
if (p.v.norm() <= 1e-15) throw scad::ValueError("Cannot normalize a zero-length vector");
|
||||
return PyVec3{p.v.normalized()};
|
||||
})
|
||||
.def("getAngle", [](const PyVec3& p, const scad::Vec3& o) {
|
||||
const double sn = p.v.norm(), on = o.norm();
|
||||
if (sn <= 1e-15 || on <= 1e-15) throw scad::ValueError("Cannot compute angle with a zero-length vector");
|
||||
return std::acos(std::max(-1.0, std::min(1.0, p.v.dot(o) / (sn * on))));
|
||||
})
|
||||
.def("normalized",
|
||||
[](const PyVec3& p) {
|
||||
if (p.v.norm() <= 1e-15)
|
||||
throw scad::ValueError("Cannot normalize a zero-length vector");
|
||||
return PyVec3{p.v.normalized()};
|
||||
})
|
||||
.def("getAngle",
|
||||
[](const PyVec3& p, const scad::Vec3& o) {
|
||||
const double sn = p.v.norm(), on = o.norm();
|
||||
if (sn <= 1e-15 || on <= 1e-15)
|
||||
throw scad::ValueError("Cannot compute angle with a zero-length vector");
|
||||
return std::acos(std::max(-1.0, std::min(1.0, p.v.dot(o) / (sn * on))));
|
||||
})
|
||||
.def("__mul__", [](const PyVec3& p, double s) { return PyVec3{p.v * s}; })
|
||||
.def("__rmul__", [](const PyVec3& p, double s) { return PyVec3{p.v * s}; })
|
||||
.def("__repr__", [](const PyVec3& p) {
|
||||
@@ -64,8 +68,10 @@ void bind_core(py::module_& m) {
|
||||
.def_property_readonly("x_axis", [](const CoordinateSystem& c) { return as_array(c.x_axis()); })
|
||||
.def_property_readonly("y_axis", [](const CoordinateSystem& c) { return as_array(c.y_axis()); })
|
||||
.def_property_readonly("z_axis", [](const CoordinateSystem& c) { return as_array(c.z_axis()); })
|
||||
.def("transform_point", [](const CoordinateSystem& c, const py::object& p) { return as_array(c.transform_point(vec_from_python(p))); })
|
||||
.def("transform_vector", [](const CoordinateSystem& c, const py::object& v) { return as_array(c.transform_vector(vec_from_python(v))); })
|
||||
.def("transform_point", [](const CoordinateSystem& c,
|
||||
const py::object& p) { return as_array(c.transform_point(vec_from_python(p))); })
|
||||
.def("transform_vector", [](const CoordinateSystem& c,
|
||||
const py::object& v) { return as_array(c.transform_vector(vec_from_python(v))); })
|
||||
.def("_format_string", &CoordinateSystem::to_string, py::arg("indent") = 0)
|
||||
.def("__str__", [](const CoordinateSystem& c) { return c.to_string(0); })
|
||||
.def("__repr__", &CoordinateSystem::repr);
|
||||
@@ -75,12 +81,19 @@ void bind_core(py::module_& m) {
|
||||
|
||||
py::class_<Workplane>(m, "SimpleWorkplane")
|
||||
.def(py::init([](const py::object& origin, const py::object& normal, const py::object& x_dir) {
|
||||
return std::make_unique<Workplane>(vec_from_python(origin), vec_from_python(normal), vec_from_python(x_dir));
|
||||
return std::make_unique<Workplane>(vec_from_python(origin), vec_from_python(normal),
|
||||
vec_from_python(x_dir));
|
||||
}),
|
||||
py::arg("origin") = py::make_tuple(0, 0, 0), py::arg("normal") = py::make_tuple(0, 0, 1),
|
||||
py::arg("x_dir") = py::make_tuple(1, 0, 0))
|
||||
.def_property_readonly("cs", &Workplane::cs, py::return_value_policy::reference_internal)
|
||||
.def("__enter__", [](Workplane& w) -> Workplane& { w.enter(); return w; }, py::return_value_policy::reference)
|
||||
.def(
|
||||
"__enter__",
|
||||
[](Workplane& w) -> Workplane& {
|
||||
w.enter();
|
||||
return w;
|
||||
},
|
||||
py::return_value_policy::reference)
|
||||
.def("__exit__", [](Workplane& w, const py::object&, const py::object&, const py::object&) { w.exit(); })
|
||||
.def("_format_string", &Workplane::to_string, py::arg("indent") = 0, py::arg("show_coordinate_system") = true)
|
||||
.def("__str__", [](const Workplane& w) { return w.to_string(0, true); })
|
||||
|
||||
Reference in New Issue
Block a user