Ask questions from experts!

Source: Internet
Author: User
Ask questions from experts! -- Linux general technology-Linux programming and kernel information. The following is a detailed description. When editing the following program, the system prompts that the Norm functions of lines 121st and 157 are not declared in the scope. This is a large program and I can only provide this header file! Please help !!
//************************************** ****************************************
// ** Scatm Ech: Polarized Light Scattering C ++ Class Library
//**
// ** File: vector3d. h
//**
// ** Thomas A. Germer
// ** Optical Technology Division, National Institute of Standards and Technology
// ** 100 Bureau Dr. Stop 8442; Gaithersburg, MD 20899-8442
// ** Phone: (301) 975-2876; FAX: (301) 840-8551
// * Email: thomas.germer@nist.gov
//**
// ** Version: 3.01 (May 2002)
//**
//************************************** ****************************************
# Ifndef SCATMECH_VECTOR3D_H
# Define SCATMECH_VECTOR3D_H
# Include "scatm Ech. h"
# Ifndef NO_SCATMECH_NAMESPACE
Namespace scatm Ech {
# Endif // NO_SCATMECH_NAMESPACE
//
// Template class Vector3D_Base is used by the class Vector3D
//
Template
Class Vector3D_Base {
Public:
//
// The components of the vector:
//
TYPE x, y, z;
// Class constructors:
Vector3D_Base (){}
Vector3D_Base (Const TYPE & a, const TYPE & B, const TYPE & c)
{X = a; y = B; z = c ;}

// Class destructor:
Virtual ~ Vector3D_Base (){}
// Non-converting copy constructor:
Vector3D_Base (Const Vector3D_Base &)
: X (a. x), y (a. y), z (a. z ){}
// Assignment operator:
Vector3D_Base & Operator = (const Vector3D_Base &)
{X = a. x; y = a. y; z = a. z; return * this ;}

// Addition of vectors:
Vector3D_Base Operator + (const Vector3D_Base & A) const
{Return Vector3D_Base (X + a. x, y + a. y, z + a. z );}

// Subtraction of vectors:
Vector3D_Base Operator-(const Vector3D_Base & A) const
{Return Vector3D_Base (X-a.x, y-a.y, z-a.z );}

// Unary minus sign:
Vector3D_Base Operator-() const
{Return Vector3D_Base (-X,-y,-z );}

// Scalar product of two vectors:
TYPE operator * (const Vector3D_Base & A) const
{Return x * a. x + y * a. y + z * a. z ;}

// Product of vector with scalar:
Vector3D_Base Operator * (const TYPE & B) const
{Return Vector3D_Base (X * B, y * B, z * B );}
Friend Vector3D_Base Operator * (const TYPE & B,
Const Vector3D_Base &)
{Return Vector3D_Base (A. x * B, a. y * B, a. z * B );}

// Division of a vector by a scalar:
Vector3D_Base Operator/(const TYPE & a) const
{Return Vector3D_Base (X/a, y/a, z/);}

// The cross product of two vectors:
Friend Vector3D_Base Cross (const Vector3D_Base &,
Const Vector3D_Base & B)
{Return Vector3D_Base (A. y * B. z-a.z * B. y,
A. z * B. x-a.x * B. z,
A. x * B. y-a.y * B. x );}

Protected:

// A type-converting copy function:
Template
Void copy (const Vector3D_Base &)
{X = a. x; y = a. y; z = a. z ;}
};
//
// Define templated Vector3D
//
Template Class Vector3D: public Vector3D_Base {};
//
// Define Vector3D
//
Template <>
Class Vector3D : Public Vector3D_Base {
Public:
// Constructors:
Vector3D (){};
Vector3D (Const Vector3D &)
: Vector3D_Base (){}
Vector3D (Const Vector3D_Base &)
: Vector3D_Base (){}
Vector3D (Double ax, double ay, double az)
: Vector3D_Base (Ax, ay, az ){}

// The norm of a vector:
Friend double Norm (const Vector3D_Base &)
{Return sqrt (sqr (a. x) + sqr (a. y) + sqr (a. z ));}
// A vector of unit length:
Friend Vector3D Unit (const Vector3D_Base &)
{Return a/Norm ();}
// A function returning a vector having specific polar coordinates:
Friend Vector3D_Base Polar (double r, double theta, double phi ){
Return Vector3D_Base (R * sin (theta) * cos (phi ),
R * sin (theta) * sin (phi ),
R * cos (theta ));
}
};
//
// Defining Vector3D
//
Template <>
Class Vector3D : Public Vector3D_Base {
Public:
// Constructors:
Vector3D (){};
Vector3D (Const Vector3D &)
: Vector3D_Base (){}
Vector3D (Const Vector3D_Base &)
: Vector3D_Base (){}
Vector3D (Const COMPLEX & ax,
Const COMPLEX & ay,
Const COMPLEX & az)
: Vector3D_Base (Ax, ay, az ){}
// Constructor which converts from a real vector to a complex vector:
Vector3D (Const Vector3D_Base & A) {copy ();}
// The norm of a complex vector:
Friend COMPLEX Norm (const Vector3D_Base &)
{Return std: sqrt (sqr (a. x) + sqr (a. y) + sqr (a. z ));}
// A vector of unit length:
Friend Vector3D Unit (const Vector3D_Base &)
{Return a/Norm ();}
};
// A vector perpendicular to two vectors:
Vector3D Perpto (const Vector3D &,
Const Vector3D & B );
Vector3D Perpto (const Vector3D &,
Const Vector3D & B );
// Some useful typedefs for the scatm Ech library:
Typedef Vector3D Vector;
Typedef Vector3D CVector;
# Ifndef NO_SCATMECH_NAMESPACE
} // Namespace scatm Ech
# Endif // NO_SCATMECH_NAMESPACE
# Endif // VECTOR3D_H

[ This post was last edited by APFNTCHUO]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.