Nothing in EVE is truly free. Even if you mine the minerals and make the end product yourself, it wasn't free. You always have the choice to use those minerals to make the finished product or to sell them to someone else. This is the Opportunity Cost of the item.
For example, you mine 333 units of Veldspar (one refine). Your first opportunity to make the most money from that Veldspar is by selling it unrefined versus refining it and selling the Tritanium. There are a few variables in this particular equation that can tip the balance one way or another, such as refining skills and standing where you are going to refine, as well as local market prices.
Refining skills and standing mean you may not end up with the complete 1000 units of Tritanium contained in that 333 units of Veldspar. Use the refining window to see what is the actual number of Tritanium units you will end up with. (Or a link to the right article on the wiki to explain that better.)
Local market conditions in this case refer to the Opportunity Cost of taking the materials some distance away to get the best price in the region. If you take the goods to some other system; you may get better pricing, but you will be flying back and forth some number of jumps for some period of time that you could be making more ISK mining.
The short summary for Opportunity Cost is that you should do the math before making a decision on what to do with whatever material you have. It may be more beneficial to your wallet to sell the Veldspar (or Tritanium) and buy the other finished good you were interested in making.
One thing overlooked by most players is the cost of production itself. If you are going to make Shuttles from the Tritanium you refined from the Veldspar you collected. You should also consider the cost of the blueprint (and any research done) as well as the cost of the factory slot rental.
You may choose not to consider the blueprint costs in each production run, but at some point you hoped to be making money off of that blueprint didn't you? If you're just collecting blueprints to have them, it's probably not an issue to factor into your profit equations. If you're serious about making more money, then every ISK tied up in a blueprint is an investment that you want paid off and turned into an investment that is paying you every time you use it.
It is probably best to consider the return on investment (ROI) as part of some multiple of runs produced. After which you have "paid yourself back" for the initial investment in the BPO. That portion of the production cost then moves from the cost side to the profit side. If you want to consider the ROI in the blueprint over some time-frame, this will likely dictate how many units you will have to produce over that time-frame to reach the break even point.
Opportunity Cost Equations
Your Simple equation for Value desision is described as: Op Verses Rp Verses Ip (Where Op is the Price of selling the Ore you have, Rp is the Price of Selling the Minerals refined from the Ore you have, and Ip is the Net value you gain by selling your item)
When Op < Rp > Ip you should refine your Ore and sell the Minerals, forgoing building your item
When Op > Rp > Ip you should sell your Ore directly forgoing refining or building an item
When Op < Rp < Ip you should refine your ore and build your item
How to find Op
Op = Ou * Ob
(Where Ou = the number of units of Ore, and Ob = the price you can sell a unit of Ore for)
How to Find Ip
Ip = Sp - Bc
How to Find Rp
Rp = (Tu * Tp) + (Pu * Pp) + (Mu * Mp) + (Iu * Ip) + (Nu * Np) + (Zu * Zp) + (MGu * MGp) + (MPu * MPp)
(Where T = Tritanium, P = Pyerite, M = Mexallon, I = Isogen, N = Nocxium, Z = Zydrine, MG = Megacyte, and MP = Morphite; While subscript u indicates the number of Units of the Mineral, Subscript p indicates the sell price of a unit of the respective Mineral)
Return on Investment Equations
Total production costs are broken down in simple chunks like this: (Blueprint Costs / ROI Runs) + (Materials Cost) + (Factory Cost) = Cost of Production
Blueprint Costs are the initial cost of the print itself as well as the cost of any research done so far. By dividing it by the ROI Runs expectation, you are portioning it out per run. Remove it from the equation when you have produced that many runs of the material. Blueprint Cost can also represent the cost of invention. It would be the cost of the datacores, decryptors, base items and the copies (and may include a portion of the cost of the original print as well) that went into the invention process.
And the most important formula of all, profit: Profit = Sale Price - Cost of Production
If Profit is negative, you're throwing money away for some reason. If it's marginal, only a few ISK per item, then you can probably find something more profitable somewhere else.