本文整理汇总了C++中base::Vector3d类的典型用法代码示例。如果您正苦于以下问题:C++ Vector3d类的具体用法?C++ Vector3d怎么用?C++ Vector3d使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vector3d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scale
PyObject* MatrixPy::scale(PyObject * args)
{
double x,y,z;
Base::Vector3d vec;
PyObject *pcVecObj;
if (PyArg_ParseTuple(args, "ddd", &x,&y,&z)) { // convert args: Python->C
vec.x = x;
vec.y = y;
vec.z = z;
}
else if (PyArg_ParseTuple(args, "O!:three floats or a vector is needed",
&PyTuple_Type, &pcVecObj)) {
vec = getVectorFromTuple<double>(pcVecObj);
// clears the error from the first PyArg_ParseTuple()6
PyErr_Clear();
}
else if (PyArg_ParseTuple(args, "O!:three floats or a vector is needed", &(Base::VectorPy::Type), &pcVecObj)) {
// convert args: Python->C
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(pcVecObj);
Base::Vector3d* val = pcObject->getVectorPtr();
vec.Set(val->x,val->y,val->z);
// clears the error from the first PyArg_ParseTuple()6
PyErr_Clear();
}
else
return NULL;
PY_TRY {
getMatrixPtr()->scale(vec);
}
PY_CATCH;
Py_Return;
}
示例2: getViewAxis
/// utility non-class member functions
//! gets a coordinate system that matches view system used in 3D with +Z up (or +Y up if neccessary)
//! used for individual views, but not secondary views in projection groups
gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin,
const Base::Vector3d& direction,
const bool flip)
{
gp_Pnt inputCenter(origin.x,origin.y,origin.z);
Base::Vector3d stdZ(0.0,0.0,1.0);
Base::Vector3d flipDirection(direction.x,-direction.y,direction.z);
if (!flip) {
flipDirection = Base::Vector3d(direction.x,direction.y,direction.z);
}
Base::Vector3d cross = flipDirection;
//special cases
if (flipDirection == stdZ) {
cross = Base::Vector3d(1.0,0.0,0.0);
} else if (flipDirection == (stdZ * -1.0)) {
cross = Base::Vector3d(1.0,0.0,0.0);
} else {
cross.Normalize();
cross = cross.Cross(stdZ);
}
gp_Ax2 viewAxis;
viewAxis = gp_Ax2(inputCenter,
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z),
// gp_Dir(1.0, 1.0, 0.0));
gp_Dir(cross.x, cross.y, cross.z));
return viewAxis;
}
示例3: transform
PyObject* MatrixPy::transform(PyObject * args)
{
Base::Vector3d vec;
Matrix4D mat;
PyObject *pcVecObj,*pcMatObj;
if (PyArg_ParseTuple(args, "O!O!: a transform point (Vector) and a transform matrix (Matrix) is needed",
&(Base::VectorPy::Type), &pcVecObj, &(MatrixPy::Type), &pcMatObj) ) { // convert args: Python->C
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(pcVecObj);
Base::Vector3d* val = pcObject->getVectorPtr();
vec.Set(val->x,val->y,val->z);
mat = *(static_cast<MatrixPy*>(pcMatObj)->getMatrixPtr());
// clears the error from the first PyArg_ParseTuple()6
PyErr_Clear();
}
else
return NULL; // NULL triggers exception
PY_TRY {
getMatrixPtr()->transform(vec,mat);
}
PY_CATCH;
Py_Return;
}
示例4: setColor
void TrajectoryVisualization::setColor(const base::Vector3d& color)
{
{ boost::mutex::scoped_lock lockit(this->updateMutex);
this->color = osg::Vec4(color.x(), color.y(), color.z(), 1.0); }
emit propertyChanged("Color");
setDirty();
}
示例5: computeFinalParameters
Extrusion::ExtrusionParameters Extrusion::computeFinalParameters()
{
Extrusion::ExtrusionParameters result;
Base::Vector3d dir;
switch(this->DirMode.getValue()){
case dmCustom:
dir = this->Dir.getValue();
break;
case dmEdge:{
bool fetched;
Base::Vector3d base;
fetched = fetchAxisLink(this->DirLink, base, dir);
if (! fetched)
throw Base::Exception("DirMode is set to use edge, but no edge is linked.");
this->Dir.setValue(dir);
}break;
case dmNormal:
dir = calculateShapeNormal(this->Base);
this->Dir.setValue(dir);
break;
default:
throw Base::ValueError("Unexpected enum value");
}
if(dir.Length() < Precision::Confusion())
throw Base::ValueError("Direction is zero-length");
result.dir = gp_Dir(dir.x, dir.y, dir.z);
if (this->Reversed.getValue())
result.dir.Reverse();
result.lengthFwd = this->LengthFwd.getValue();
result.lengthRev = this->LengthRev.getValue();
if(fabs(result.lengthFwd) < Precision::Confusion()
&& fabs(result.lengthRev) < Precision::Confusion() ){
result.lengthFwd = dir.Length();
}
if (this->Symmetric.getValue()){
result.lengthRev = result.lengthFwd * 0.5;
result.lengthFwd = result.lengthFwd * 0.5;
}
if (fabs(result.lengthFwd + result.lengthRev) < Precision::Confusion())
throw Base::ValueError("Total length of extrusion is zero.");
result.solid = this->Solid.getValue();
result.taperAngleFwd = this->TaperAngle.getValue() * M_PI / 180.0;
if (fabs(result.taperAngleFwd) > M_PI * 0.5 - Precision::Angular() )
throw Base::ValueError("Magnitude of taper angle matches or exceeds 90 degrees. That is too much.");
result.taperAngleRev = this->TaperAngleRev.getValue() * M_PI / 180.0;
if (fabs(result.taperAngleRev) > M_PI * 0.5 - Precision::Angular() )
throw Base::ValueError("Magnitude of taper angle matches or exceeds 90 degrees. That is too much.");
result.faceMakerClass = this->FaceMakerClass.getValue();
return result;
}
示例6: transformToOutside
Base::Vector3d MeshObject::getPointNormal(unsigned long index) const
{
std::vector<Base::Vector3f> temp = _kernel.CalcVertexNormals();
Base::Vector3d normal = transformToOutside(temp[index]);
// the normal is a vector, hence we must not apply the translation part
// of the transformation to the vector
normal.x -= _Mtrx[0][3];
normal.y -= _Mtrx[1][3];
normal.z -= _Mtrx[2][3];
normal.Normalize();
return normal;
}
示例7: updateDataIntern
void TrajectoryVisualization::updateDataIntern( const base::Vector3d& data )
{
if(doClear)
{
points.clear();
doClear = false;
}
Point p;
p.point = osg::Vec3(data.x(), data.y(), data.z());
p.color = color;
points.push_back(p);
while(points.size() > max_number_of_points)
points.pop_front();
}
示例8: findOneClosestPoint
base::Vector3d SplineBase::poseError(base::Vector3d _position, double _heading, double _guess)
{
double param = findOneClosestPoint(_position.data(), _guess, getGeometricResolution());
// Returns the error [distance error, orientation error, parameter]
return base::Vector3d(distanceError(_position, param), headingError(_heading, param), param);
}
示例9: setDirection
void LocationWidget::setDirection(const Base::Vector3d& dir)
{
if (dir.Length() < Base::Vector3d::epsilon()) {
return;
}
// check if the user-defined direction is already there
for (int i=0; i<dValue->count()-1; i++) {
QVariant data = dValue->itemData (i);
if (data.canConvert<Base::Vector3d>()) {
const Base::Vector3d val = data.value<Base::Vector3d>();
if (val == dir) {
dValue->setCurrentIndex(i);
return;
}
}
}
// add a new item before the very last item
QString display = QString::fromLatin1("(%1,%2,%3)")
.arg(dir.x)
.arg(dir.y)
.arg(dir.z);
dValue->insertItem(dValue->count()-1, display,
QVariant::fromValue<Base::Vector3d>(dir));
dValue->setCurrentIndex(dValue->count()-2);
}
示例10: cMeshEval
Base::Matrix4D MeshObject::getEigenSystem(Base::Vector3d& v) const
{
MeshCore::MeshEigensystem cMeshEval(_kernel);
cMeshEval.Evaluate();
Base::Vector3f uvw = cMeshEval.GetBoundings();
v.Set(uvw.x, uvw.y, uvw.z);
return cMeshEval.Transform();
}
示例11: on_direction_activated
void LocationWidget::on_direction_activated(int index)
{
// last item is selected to define direction by user
if (index+1 == dValue->count()) {
bool ok;
Base::Vector3d dir = this->getUserDirection(&ok);
if (ok) {
if (dir.Length() < Base::Vector3d::epsilon()) {
QMessageBox::critical(this, LocationDialog::tr("Wrong direction"),
LocationDialog::tr("Direction must not be the null vector"));
return;
}
setDirection(dir);
}
}
}
示例12: stdX
//! calculate the section Normal/Projection Direction given baseView projection direction and section name
Base::Vector3d DrawViewSection::getSectionVector (const std::string sectionName)
{
Base::Vector3d result;
Base::Vector3d stdX(1.0,0.0,0.0);
Base::Vector3d stdY(0.0,1.0,0.0);
Base::Vector3d stdZ(0.0,0.0,1.0);
double adjustAngle = 0.0;
if (getBaseDPGI() != nullptr) {
adjustAngle = getBaseDPGI()->getRotateAngle();
}
Base::Vector3d view = getBaseDVP()->Direction.getValue();
view.Normalize();
Base::Vector3d left = view.Cross(stdZ);
left.Normalize();
Base::Vector3d up = view.Cross(left);
up.Normalize();
double dot = view.Dot(stdZ);
if (sectionName == "Up") {
result = up;
if (DrawUtil::fpCompare(dot,1.0)) { //view = stdZ
result = (-1.0 * stdY);
} else if (DrawUtil::fpCompare(dot,-1.0)) { //view = -stdZ
result = stdY;
}
} else if (sectionName == "Down") {
result = up * -1.0;
if (DrawUtil::fpCompare(dot,1.0)) { //view = stdZ
result = stdY;
} else if (DrawUtil::fpCompare(dot, -1.0)) { //view = -stdZ
result = (-1.0 * stdY);
}
} else if (sectionName == "Left") {
result = left * -1.0;
if (DrawUtil::fpCompare(fabs(dot),1.0)) { //view = +/- stdZ
result = stdX;
}
} else if (sectionName == "Right") {
result = left;
if (DrawUtil::fpCompare(fabs(dot),1.0)) {
result = -1.0 * stdX;
}
} else {
Base::Console().Log("Error - DVS::getSectionVector - bad sectionName: %s\n",sectionName.c_str());
result = stdZ;
}
Base::Vector3d adjResult = DrawUtil::vecRotate(result,adjustAngle,view);
return adjResult;
}
示例13: onChanged
void ConstraintForce::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
if (getPoints(points, normals)) {
Points.setValues(points); // We don't use the normals because all arrows should have the same direction
}
} else if (prop == &Direction) {
Base::Vector3d direction = getDirection(Direction);
if (direction.Length() < Precision::Confusion())
return;
naturalDirectionVector = direction;
if (Reversed.getValue())
direction = -direction;
DirectionVector.setValue(direction);
} else if (prop == &Reversed) {
// if the direction is invalid try to compute it again
if (naturalDirectionVector.Length() < Precision::Confusion()) {
naturalDirectionVector = getDirection(Direction);
}
if (naturalDirectionVector.Length() >= Precision::Confusion()) {
if (Reversed.getValue() && (DirectionVector.getValue() == naturalDirectionVector)) {
DirectionVector.setValue(-naturalDirectionVector);
} else if (!Reversed.getValue() && (DirectionVector.getValue() != naturalDirectionVector)) {
DirectionVector.setValue(naturalDirectionVector);
}
}
} else if (prop == &NormalDirection) {
// Set a default direction if no direction reference has been given
if (Direction.getValue() == NULL) {
Base::Vector3d direction = NormalDirection.getValue();
if (Reversed.getValue())
direction = -direction;
DirectionVector.setValue(direction);
naturalDirectionVector = direction;
}
}
}
示例14: fetchAxisLink
bool Extrusion::fetchAxisLink(const App::PropertyLinkSub& axisLink, Base::Vector3d& basepoint, Base::Vector3d& dir)
{
if (!axisLink.getValue())
return false;
if (!axisLink.getValue()->isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::TypeError("AxisLink has no OCC shape");
Part::Feature* linked = static_cast<Part::Feature*>(axisLink.getValue());
TopoDS_Shape axEdge;
if (axisLink.getSubValues().size() > 0 && axisLink.getSubValues()[0].length() > 0){
axEdge = linked->Shape.getShape().getSubShape(axisLink.getSubValues()[0].c_str());
} else {
axEdge = linked->Shape.getValue();
}
if (axEdge.IsNull())
throw Base::ValueError("DirLink shape is null");
if (axEdge.ShapeType() != TopAbs_EDGE)
throw Base::TypeError("DirLink shape is not an edge");
BRepAdaptor_Curve crv(TopoDS::Edge(axEdge));
gp_Pnt startpoint;
gp_Pnt endpoint;
if (crv.GetType() == GeomAbs_Line){
startpoint = crv.Value(crv.FirstParameter());
endpoint = crv.Value(crv.LastParameter());
if (axEdge.Orientation() == TopAbs_REVERSED)
std::swap(startpoint, endpoint);
} else {
throw Base::TypeError("DirLink edge is not a line.");
}
basepoint.Set(startpoint.X(), startpoint.Y(), startpoint.Z());
gp_Vec vec = gp_Vec(startpoint, endpoint);
dir.Set(vec.X(), vec.Y(), vec.Z());
return true;
}
示例15: move
PyObject* MeshPointPy::move(PyObject *args)
{
if (!getMeshPointPtr()->isBound())
PyErr_SetString(Base::BaseExceptionFreeCADError, "This object is not bounded to a mesh, so no topological operation is possible!");
double x=0.0,y=0.0,z=0.0;
PyObject *object;
Base::Vector3d vec;
if (PyArg_ParseTuple(args, "ddd", &x,&y,&z)) {
vec.Set(x,y,z);
}
else if (PyArg_ParseTuple(args,"O!",&(Base::VectorPy::Type), &object)) {
PyErr_Clear(); // set by PyArg_ParseTuple()
// Note: must be static_cast, not reinterpret_cast
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
}
else {
return 0;
}
getMeshPointPtr()->Mesh->movePoint(getMeshPointPtr()->Index,vec);
Py_Return;
}