Browse Source

直线类增加set方法

master
blobt 4 years ago
parent
commit
5bfb6da40f
  1. BIN
      .vs/3dMath/v15/.suo
  2. 22
      GMath.cpp
  3. 6
      GMath.h
  4. 7
      main.cpp

BIN
.vs/3dMath/v15/.suo

22
GMath.cpp

@ -1062,3 +1062,25 @@ GPoint3 GLine::operator()(const float t) const
{ {
return p + v*t; return p + v*t;
} }
GLine & GLine::SetPt(const GPoint3 & _p)
{
p = _p;
return *this;
}
GLine & GLine::SetDir(const GVector3 & _v)
{
v = _v;
return *this;
}
GVector3 GLine::GetPt() const
{
return p;
}
GVector3 GLine::GetDir() const
{
return v;
}

6
GMath.h

@ -216,4 +216,10 @@ public:
GLine& operator =(const GLine& rhs); GLine& operator =(const GLine& rhs);
GPoint3 operator ()(const float t) const; GPoint3 operator ()(const float t) const;
GLine& SetPt(const GPoint3& _p);
GLine& SetDir(const GVector3& _v);
GVector3 GetPt() const;
GVector3 GetDir() const;
}; };

7
main.cpp

@ -6,6 +6,11 @@ int main() {
GPoint3 p = l(2.0f); GPoint3 p = l(2.0f);
cout << p << endl;
l.SetPt(GPoint3(0.0f, 0.0f, 1.0f));
l.SetDir(GVector3(1.0f, 0.0f, 0.0f));
GPoint3 q = l(1.0f);
cout << q << endl;
return 0; return 0;
} }
Loading…
Cancel
Save