本文整理汇总了C++中Normal函数的典型用法代码示例。如果您正苦于以下问题:C++ Normal函数的具体用法?C++ Normal怎么用?C++ Normal使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Normal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uniform_sphere_sample
Point SphereShape::sample_point(float u1, float u2,
Normal& out_n, float& out_ray_epsilon) const
{
Vec3 w = uniform_sphere_sample(u1, u2);
out_n = Normal(w);
out_ray_epsilon = 5e-3f * this->radius;
return Point() + Vector(w * this->radius);
}
示例2: Compound
// ---------------------------------------------------------------- copy constructor
SolidCylinder::SolidCylinder(const SolidCylinder& cyl)
: Compound(cyl),
bottom(cyl.bottom),
top(cyl.top),
radius(cyl.radius),
box(Point3D(-1.0*radius,bottom , -1.0*radius),
Point3D(1.0*radius,top , 1.0*radius))
{objects.push_back(new Disk(Point3D(0, bottom, 0),
Normal(0, -1, 0),
radius));
objects.push_back(new Disk(Point3D(0, top, 0),
Normal(0, 1, 0),
radius));
objects.push_back(new OpenCylinder(bottom,top,radius));}
示例3: Normal
Vector2D Vector2D::Reflect(const Vector2D & v, const Vector2D &a) {
Vector2D n = Normal(a);
float co = -2 * ((float)v.Dot(n) / (n.Magnitude() * n.Magnitude()));
Vector2D r = {};
r.x = v.x + co * n.x;
r.y = r.y + co * n.y;
return r;
}
示例4: rotate
D3DXVECTOR3 rotate(D3DXVECTOR3 v, Quaternion q) {
Quaternion q_, qv;
q = Normal(q);
q_.w = q.w; q_.x = -q.x; q_.y = -q.y; q_.z = -q.z;
qv.w = 0; qv.x=v.x; qv.y=v.y; qv.z=v.z;
Quaternion aa= q_*qv*q;
return D3DXVECTOR3(aa.x, aa.y, aa.z);
}
示例5: Lerp
Point Cylinder::Sample(float u1, float u2, Normal *Ns) const {
float z = Lerp(u1, zmin, zmax);
float t = u2 * phiMax;
Point p = Point(radius * cosf(t), radius * sinf(t), z);
*Ns = Normalize((*ObjectToWorld)(Normal(p.x, p.y, 0.)));
if (ReverseOrientation) *Ns *= -1.f;
return (*ObjectToWorld)(p);
}
示例6: DoesIntersect
bool DistanceEstimator::Intersect(const Ray &r, float *tHit, float *rayEpsilon,
DifferentialGeometry *dg) const {
bool succeed = DoesIntersect(r, tHit);
if (!succeed) return false;
Ray ray;
(*WorldToObject)(r, &ray);
Point p = ray(*tHit);
*rayEpsilon = DE_params.hitEpsilon * DE_params.rayEpsilonMultiplier;
Vector n = CalculateNormal(p, DE_params.normalEpsilon);
Vector DPDU, DPDV;
CoordinateSystem(n, &DPDU, &DPDV);
const Transform &o2w = *ObjectToWorld;
*dg = DifferentialGeometry(o2w(p), o2w(DPDU), o2w(DPDV), Normal(), Normal(), 0, 0, this);
return true;
}
示例7: SCDebugPrint
Point3 SContext::DP(void)
{
SCDebugPrint("SContext::DP\n");
float d = (1.0f+DFACT)*0.1f/(DFACT+(float)fabs(DotProd(Normal(),viewDir)));
dp = Point3(d,d,d);
return dp;
}
示例8: FileGetZeroedChunk
boolean FileGetZeroedChunk (vbntype VbnBlk, blkhdrtype *BlkHdr,
boolean Release,
ft F,lt Z,zz *Status, numtype *Chunk)
{
bytessize UnitSize = 0;
indextype UnitCount = 0;
bytessize ChunkSize = 0;
vbntype ChunkRefVbn = VbnBlk;
chunkstruc ChunkRef;
chunkstruc *ChunkRefPtr = &ChunkRef;
addrtype ChunkAddr = NullPtr;
/* Load Chunk Struc Into Core */
if (FileInBlk ((addrtype *)&ChunkRefPtr, sizeof(chunkstruc),
BlkHdr, Release, McStat, &ChunkRefVbn))
{
UnitSize = ChunkRefPtr->UnitSize;
UnitCount = ChunkRefPtr->UnitCount;
ChunkSize = UnitCount * UnitSize;
if (!*Chunk)
MemMakeChunk (UnitSize, UnitCount, ChunkRef.ExtendQty,
DbmDbId, McStat, Chunk);
if (Normal(*Status))
MemPutStackPtr (*Chunk, ChunkRef.StackPtr, McStat);
if (!ChunkSize)
if (sprintf (Msg, TraceStr(43),
/* " ZERO BLOCK [%3u] ZERO Chunk[%4u](%2u * %2u)\n" */
VbnBlk, *Chunk, UnitCount, UnitSize))
TraceMsg (0, Msg);
if (MemGetChunkAddr (*Chunk, McStat, &ChunkAddr))
memset (ChunkAddr, NULL, (size_t )ChunkSize);
}
if (Normal(*Status))
if (DeBug)
MemDumpChunk (0, *Chunk, McStat);
TRACK(TrackBak,"FileGetZeroedChunk\n");
return(STAT);
}
示例9: PrependTabs
void CBasePoly::SaveBasePolyLTA( CLTAFile* pFile, uint32 level )
{
uint32 i;
//write out the list of face indices
PrependTabs(pFile, level);
pFile->WriteStr("( f ");
for( i=0; i < m_Indices; i++ ){
pFile->WriteStrF("%i ", m_Indices[i] );
}
pFile->WriteStr(")");
//write out the surface normal
PrependTabs(pFile, level);
pFile->WriteStrF("( n %f %f %f )", Normal().x, Normal().y, Normal().z );
PrependTabs(pFile, level);
pFile->WriteStrF("( dist %f )", Dist() );
}
示例10: Student
double Student(long n)
/* ===========================================
* Returns a student-t distributed real number.
* NOTE: use n > 0
* ===========================================
*/
{
return (Normal(0.0, 1.0) / sqrt(Chisquare(n) / n));
}
示例11: Lognormal
double Lognormal(double a, double b)
/* ====================================================
* Returns a lognormal distributed positive real number.
* NOTE: use b > 0.0
* ====================================================
*/
{
return (exp(a + b * Normal(0.0, 1.0)));
}
示例12: sampleEmissionArea
void sampleEmissionArea(EmissionRecord &eRec, const Point2 &sample) const {
if (eRec.type == EmissionRecord::ENormal) {
Vector d = squareToSphere(sample);
eRec.sRec.p = m_bsphere.center + d * m_bsphere.radius;
eRec.sRec.n = Normal(-d);
eRec.pdfArea = 1.0f / (4 * M_PI * m_bsphere.radius * m_bsphere.radius);
eRec.value = Spectrum(M_PI);
} else {
/* Preview mode, which is more suitable for VPL-based rendering: approximate
the infinitely far-away source with set of diffuse point sources */
const Float radius = m_bsphere.radius * 1.5f;
Vector d = squareToSphere(sample);
eRec.sRec.p = m_bsphere.center + d * radius;
eRec.sRec.n = Normal(-d);
eRec.pdfArea = 1.0f / (4 * M_PI * radius * radius);
eRec.value = Le(d) * M_PI;
}
}
示例13: samplePosition
void samplePosition(PositionSamplingRecord &pRec, const Point2 &sample) const {
const Transform &trafo = m_objectToWorld->eval(pRec.time);
Point2 p = warp::squareToUniformDiskConcentric(sample);
pRec.p = trafo(Point3(p.x, p.y, 0));
pRec.n = normalize(trafo(Normal(0, 0, 1)));
pRec.pdf = m_invSurfaceArea;
pRec.measure = EArea;
}
示例14: samplePosition
Spectrum samplePosition(PositionSamplingRecord &pRec,
const Point2 &sample, const Point2 *extra) const {
const Transform &trafo = m_worldTransform->eval(pRec.time);
pRec.p = trafo(Point(0.0f));
pRec.n = Normal(0.0f);
pRec.pdf = 1.0f;
pRec.measure = EDiscrete;
return Spectrum(1.0f);
}
示例15: IntersectionPoint
void IntersectionPoint(const Circle& c1, const Circle& c2, Point& p1, Point& p2)
{
double d = Length(c1.c - c2.c);
double l = (c1.r*c1.r + d*d - c2.r*c2.r) / (2 * d);
double h = sqrt(c1.r*c1.r - l*l);
Point mid = c1.c + unit(c2.c-c1.c) * l;
Vector t = Normal(c2.c - c1.c) * h;
p1 = mid + t;
p2 = mid - t;
}