Flex: moving a point with rotation doesnt change the point XY?
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further If you just want the point after rotation, cos(r) * x, sin(r) * y is the easiest way. If you want the point after all transformations, you should be able to use displayObject.transform.transformPoint(x, y).
|
Operator +(Vector) for Point - but the Vector uses Point and it's undeclared in Point declaration
Tag : cpp , By : Josh Tegart
Date : March 29 2020, 07:55 AM
wish help you to fix your issue You can solve this by moving the function definition after the definition of Vector3D, and just declare the function in the class definition. This requires a declaration of Vector3D, but not the full definition. Also, never return a reference to a local automatic variable. // class declaration
class Vector3D;
// class declaration and definition
class Point3D {
// ...
// function declaration (only needs class declarations)
Point3D operator+(const Vector3D &) const;
};
// class definition
class Vector3D {
// ...
};
// function definition (needs class definitions)
inline Point3D Point3D::operator+(const Vector3D &vector) const {
// ...
}
|
whats the formula to point along line known starting point, ending point and distance
Tag : math , By : Ryan Adriano
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Create a normal and multiply it. I'm pretty sure there are better ways to do that though. =) Vec3 BA = B - A;
BA.normalize(); // you have the direction
Vec3 Dist = BA.mult(distance);
Vec3 Result = A + Dist;
|
Compare two std::vector<cv::Point> vectors and safe common points to a third std::vector<cv::Point>
Tag : cpp , By : TheDave1022
Date : March 29 2020, 07:55 AM
will be helpful for those in need As already mentioned by @BoBTFish and @NaCl, you need to use a custom comparator, and apply set_intersection on sorted vectors. Since you need to call the comparator three times, it's useful to use a function instead of a lambda expression. #include <opencv2/opencv.hpp>
#include <vector>
#include <algorithm>
using namespace std;
using namespace cv;
// Custom less comparator
bool lessPoints(const Point& lhs, const Point& rhs) {
return (lhs.x < rhs.x) || ((lhs.x == rhs.x) && (lhs.y < rhs.y));
}
vector<Point> intersection(vector<Point> v1, vector<Point> v2)
{
vector<Point> v3;
// Sort vectors
sort(v1.begin(), v1.end(), lessPoints);
sort(v2.begin(), v2.end(), lessPoints);
// Intersect
set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), back_inserter(v3), lessPoints);
return v3;
}
int main()
{
// Your vectors
vector<Point> v1{ Point(2,3), Point(1,2), Point(5,5), Point(3,4) };
vector<Point> v2{ Point(2,1), Point(1,2), Point(3,4), Point(6,7), Point(0,3) };
// Find intersections
vector<Point> v3 = intersection(v1, v2);
// Print out vector content
std::copy(v3.begin(), v3.end(), std::ostream_iterator<Point>(std::cout, " "));
return 0;
}
|
Coordinates of a point between two other points and know the distance from starting point and target point
Date : March 29 2020, 07:55 AM
I wish did fix the issue. How can i Find the Coorfinate of H.If There are three point that are collinear A,H,C . If it is known the two points that are at both ends like A(1.3,2.6) , C(8.1,13.7) and the distance of AH is 3.170958 . So how can I find the coordinates of H ? Here A is the starting point and C is the end point. , Find length of AC and apply formula to x and y coordinates H = A + (C-A)* Len(AH) / Len(AC)
|