Skip to content
Snippets Groups Projects
Commit 4eed6032 authored by Zain Selman's avatar Zain Selman :speech_balloon:
Browse files

small changes

parent d4902423
No related branches found
No related tags found
1 merge request!2Plane interaction
......@@ -218,29 +218,12 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
/// compute intersection
{
double u = -1, v = -1, w = -1;
// const auto ray_length = 1e6;
// const auto ray_end = origin + (viewDirection_ *
// ray_length);
rayPlaneIntersection(origin, viewDirection_, corners[0],
corners[1], corners[2], u, v);
// const auto intersect =
// ACG::Geometry::edgeConvexPolygonIntersection(
// corners, origin, ray_end, result_);
w = 1 - (u + v);
result_ = (w * corners[0]) + (u * corners[1]) + (v * corners[2]);
}
// std::cerr << "intersection found at: " << result_ <<
// std::endl; std::cerr << "target_idx: " << target_idx
// << std::endl;
// ACG::Vec3d test = curPlane_->plane().position -
// 0.5 * curPlane_->plane().xDirection
// - 0.5 *
// curPlane_->plane().yDirection;
// std::cerr << "plane 0 corner worldspace: " << test <<
// std::endl;
if (target_idx == 0)
return;
......@@ -270,9 +253,6 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
/// matrix to transform points from image plane to curPlane_
auto plane = origPlane_;
/// remeber position to do translation by hand
const auto initPos = plane.position;
/// get the world position of the projected cursor by intersecting plane
/// equation with ray
{
......@@ -304,52 +284,23 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
currWorldPos_ = (w * p0) + (u * p1) + (v * p2);
}
std::cerr << "click pos: " << result_ << std::endl;
std::cerr << "drag pos: " << currWorldPos_ << std::endl;
/// update vector in worldspace
const auto worldSpaceUpdate = (currWorldPos_ - result_) / 2.;
/// vector to clicked corner. update to corresponding corner later
// const auto distClickOrigin = plane.position + (.5f *
// plane.xDirection) +
// (.5f * plane.yDirection);
const auto distClickOrigin = result_;
/// 1. translate to origin
// plane.position -= initPos;
/*/// 2. rotate to be planar
// const auto n0 = ACG::Vec3f{plane.normal};
// const auto x = n0.dot(viewDirection_);
// const auto y = std::sqrt(1 - (x * x));
// const auto angle = std::atan2(y,x);
// std::cerr << "angle: " << angle << std::endl;
// if(angle != 0.)
// transform.rotate(angle, n0.cross(n1));*/
/// 3. scale by half updates length
/// scale by half updates length
auto transformation = ACG::GLMatrixf(ACG::Matrix4x4f());
transformation.identity(); // init
auto scale = (worldSpaceUpdate + distClickOrigin) / distClickOrigin;
scale[2] = 1; /// we dont do anything in z-dir
transformation.scale(scale[0], scale[1], scale[2]);
// const auto xscale = scale[0] * plane.xDirection.length();
// const auto yscale = scale[1] * plane.yDirection.length();
// plane.setSize(xscale, yscale);
// std::cerr << "xdir: " << plane.xDirection
// << " ydir: " << plane.yDirection << std::endl;
// std::cerr << "initial click pos: " << distClickOrigin <<
// std::endl; std::cerr << "current click pos: " << currWorldPos_
// << std::endl;
const auto xscale = scale[0] * plane.xDirection.length();
const auto yscale = scale[1] * plane.yDirection.length();
plane.setSize(xscale, yscale);
std::cerr << "scale: " << scale << std::endl;
std::cerr << "update: " << worldSpaceUpdate << std::endl;
plane.transform(transformation);
// plane.position += initPos;
plane.position += worldSpaceUpdate;
plane.position += worldSpaceUpdate / 2.;
curPlane_->plane() = plane; /// overwrite plane
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment